LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 11 Aug 2004 09:25:53 -0700
Reply-To:     "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject:      Re: Converting files from ebcdic to ascii
Comments: To: Rune Runnestoe <rune@FASTLANE.NO>
Content-Type: text/plain; charset="iso-8859-1"

Hi Rune -

I'd suggest looking into PROC TRANTAB, PROC CPORT, and PROC CIMPORT, and also the SAS/Connect references.

IIRC, the SAS ASCII/EBCDIC translation table changed between v5 and v6.

Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Rune Runnestoe Sent: Wednesday, August 11, 2004 4:50 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Converting files from ebcdic to ascii

I am trying to convert a file from ebcdic-format to ascii-format.

%let lib = utv; filename ebcdic 'd:\test\bad_files\ebcdic_file.dat'; filename ascii 'd:\test\bad_files\ascii_file.dat';

*The datastep below shows how the ascii-file looks. This file has been converted to edcdic by means of a program. I want to be able to do this convertation by using SAS-code.;

data _null_; file ascii; put 'Alfred M 14 69 113'; put 'Alice F 13 57 84'; put 'Barbara F 13 65 98'; put 'Carol F 14 63 103'; put 'Henry M 14 64 102'; put 'James M 12 57 83'; put 'Jane F 12 60 85'; put 'Janet F 15 63 113'; put 'Jeffrey M 13 63 84'; put 'John M 12 59 100'; put 'Joyce F 11 51 51'; put 'Judy F 14 64 90'; put 'Louise F 12 56 77'; put 'Mary F 15 67 112'; put 'Philip M 16 72 150'; put 'Robert M 12 65 128'; put 'Ronald M 15 67 133'; put 'Thomas M 11 58 85'; put 'William M 15 67 112'; put 'Alfred M 14 69 113'; put 'Alice F 13 57 84'; put 'Barbara F 13 65 98'; put 'Carol F 14 63 103'; put 'Henry M 14 64 103'; put 'James M 12 57 83'; put 'Jane F 12 60 85'; put 'Janet F 15 63 113'; put 'Jeffrey M 13 63 84'; put 'John M 12 59 100'; put 'Joyce F 11 51 51'; put 'Judy F 14 64 90'; put 'Louise F 12 56 77'; put 'Mary F 15 67 112'; put 'Philip M 16 72 150'; put 'Robert M 12 65 128'; put 'Ronald M 15 67 133'; put 'Thomas M 11 58 85'; put 'Alfred . . .'; put 'Alfred . . .'; run;

*Assume the file now is in edcdic-format; data _null_; infile ebcdic; input record $ebcdic80.; file ascii; put record; run;

This is the result, the file 'ascii':

Alfred M 14 69 113 Alice F 13 57 84 Barbara F

Jeffrey M 13 63 84 John M 12 59 100 Joyce F

Ronald M 15 67 133 Thomas M 11 58 85 William M

James M 12 57 83 Jane F 12 60 85 Janet F

Mary F 15 67 112 Philip M 16 72 150 Robert M

This is what the log says:

323 filename ebcdic 'd:\test\bad_files\ebcdic_file.dat'; 324 filename ascii 'd:\test\bad_files\ascii_file.dat';

325 326 327 data _null_; 328 infile ebcdic; 329 input record $ebcdic80.; 330 file ascii; 331 put record; 332 run;

NOTE: The infile EBCDIC is: File Name=d:\test\bad_files\ebcdic_file.dat, RECFM=V,LRECL=256

NOTE: The file ASCII is: File Name=d:\test\bad_files\ascii_file.dat, RECFM=V,LRECL=256

NOTE: 6 records were read from the infile EBCDIC. The minimum record length was 20. The maximum record length was 256. One or more lines were truncated. NOTE: 5 records were written to the file ASCII. The minimum record length was 79. The maximum record length was 80. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: DATA statement used (Total process time): real time 0.12 seconds cpu time 0.02 seconds

What is wrong with the code ?

Regards Rune Runnestø


Back to: Top of message | Previous page | Main SAS-L page