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 (February 1999, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 5 Feb 1999 14:09:39 GMT
Reply-To:     alte@RZ.UNI-GREIFSWALD.DE
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Shiling Zhang <shiling@MATH.WAYNE.EDU>
Organization: Deja News - The Leader in Internet Discussion
Subject:      Re: QUESTION: reading unorthodox data from flat file

Dietrich,

You can use a line holder @.

1) read the first field. 2) if the first field is a count number, then read the 2nd and 3rd fields, else read the whole line as a comment field.

3) combine those wrapped comments into one.

Hope this helps.

data t1; retain id case; length id 8 case $8 comments $100 testid $15; infile '~/test.txt' pad; input testid @; if not indexc(upcase(testid),'ABCDEFGHIJKLMNOPQRSTUVWXYZ') then do; id=input(testid, 6.); input case comments ; end; else do; input comments 1-100; end;

keep id case comments; run;

*combine comments; proc sort;by id;run;

data t2; retain id case cmtsall; length cmtsall $200; set t1; by id; if first.id then do; cmtsall=''; end; cmtsall=compbl(cmtsall||comments); if last.id then do; put id= case= cmtsall=; output; end; drop comments; run; **************************** Subject: QUESTION: reading unorthodox data from flat file Date: Thu, 4 Feb 1999 16:42:03 -0000 From: alte <alte@RZ.UNI-GREIFSWALD.DE> Organization: CM To: SAS-L@UGA.CC.UGA.EDU Newsgroups: bit.listserv.sas-l

hi,

i am trying to read ascii data into sas (6.12 NT). it looks like this

001 111112 Mein83_1 some text 002 213455 Mein83_2 other text 003 135462 Mein83_3 more text 004 351842 BESOND complications 005 no money 006 critical value 007 undetermined origin 008 321682 BESOND text 009 321654 Wohn9we Buspark

in a *standard* case the first 6 chars are an ID for the case, the second collection of chars is the variable name and after some empty spaces there comes some text. when the data typist enters line feeds, then our data entry tool (Ci3 by sawtooth) gives wrapped lines in the flat file without adding the case ID to them in the beginning. so the line text lines 005 to 007 belong to case 351842 (line 004). i don't know before when wrapped lines occur, neither how many there will be.

i would like to have the case ID in one variable and the variable name in another and the complete text for one case in a 3rd, e.g. ID VARNAME TEXT.

how could that be done?

any help would help ;-)

d. alte

------------------------------------------------------------- Dietrich Alte, Diplom-Statistiker

Universitaet Greifswald Institut fuer Epidemiologie und Sozialmedizin Organisationszentrum Community Medicine Walther-Rathenau-Str. 48 17487 Greifswald

phone +49 (0) 3834 - 86 77 13 fax +49 (0) 3834 - 86 66 84

email alte@rz.uni-greifswald.de -------------------------------------------------------------


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