LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 1996, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 Aug 1996 17:10:17 -0200
Reply-To:     Andrea Vianello <andrea@CHILD.PEDI.UNIPD.IT>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Andrea Vianello <andrea@CHILD.PEDI.UNIPD.IT>
Subject:      Reading many ascii files made of different length and structure
              of record

Dear SAS-lers,

I have 2 problems:

1) I want to read an ascii file made of different length and structure of record: the first byte of the record indicates the kind of the record. End Of Line (EOL) is put on different positions, too.

I think I have solved the problem with the macro written at the bottom of the page. (..any comments and suggestion kindly requested!)

2) There is a problem I can't resolve, that is passing filenames to the macro and make them read by it. The filenames are like these: census.001 census.002 .... census.500 .. in the directory 'c:\sas610\census'.

I work with SAS 6.10 for Win31.

Thanks Andrea Vianello

-----------------------------------

%macro read(nf=); data _null_; infile "&nf" missover pad lrecl=512 ; input kindrec 1 @; if kindrec=1 then do; input numcol 485-486; numcol=numcol-1; call symput("cn",numcol); output; end; run;

data xxx; array dati(&cn) $18.; yy=&cn; infile "&nf" missover pad lrecl=512 ;

input kindrec 1 @;

if kindrec=0 then input siglatab$ 6-13;

if kindrec=1 then input titolo$ 37-100;

if kindrec=2 then input nliv 19 progliv 20-21 nomecol$ 22-50 c_iniz 82-83 c_fine 84-85;

if kindrec=3 then do;

input progriga 19-23 tiporiga$ 24-25 nomeriga$ 26-87 @; do _i_=1 to yy; input dati(_i_) @; end; end;

if kindrec=4 then input codnota 19-21 prognota 22 testonot$ 23-50;

do _i_=1 to yy; dati(_i_)=right(dati(_i_)); end;

drop _i_ yy; run;

%mend;

-----------------------------------------------

+---------------------------------------+----------------------------------+ | Andrea Vianello | "I think there is a world market | | Gruppo di Epidemiologia | for maybe five computers." | | Dip. Pediatria Univ. di Padova | --Thomas Watson, | | v. Giustiniani,3 - 35128 Padova-Italy | chairman of IBM, 1943 | | tel 049/8213303-8213580 | | | fax 049/8213502 | "640K ought to be enough for | | e-mail andrea@child.pedi.unipd.it | anybody" --Bill Gates, 1981 | +---------------------------------------+----------------------------------+


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