Date: Thu, 8 Nov 2007 16:28:12 -0500
Reply-To: Michael Raithel <michaelraithel@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Raithel <michaelraithel@WESTAT.COM>
Subject: Re: input or list question on reading in a text file?
Content-Type: text/plain; charset="us-ascii"
Dear SAS-L-ers,
Jerry L Diebal posted the following:
> I have a file that has data like what is in the cards datastep below:
> /**********************************/
> data test;
> input datastuff $ ;
> keep datastuff ;
> cards;
> 111111-911
> 000111111
> 000038
> NAME OF CITY
> 2
> 0
> 10/31/2007
> 28
> C45
>
> 222222-911
> 000222222
> 000038
> NAME OF CITY
> 2
> 0
> 10/31/2007
> 28
> C46
>
> 333333-911
> 000333333
> 000038
> NAME OF CITY
> 2
> 0
> 10/31/2007
> 28
> C47
> ;
> /*********************************************/
>
> Each record consists of 9 lines like in the sample and each is
> separated by a blank line. The leading zeroes need to be retained on
> any variable starting with a zero. Can someone show me how to turn the
> above into a dataset? Thanks in advance.
>
Jerry,
Check out this TESTED program. It should get you pretty close to where
you need to go!
data test(drop=blankline);
input #1 @7 mixedline $16.
#2 allnums1
#3 allnums2
#4 @7 nameofcity $12.
#5 allnums3
#6 allnums4
#7 @7 bigdate mmddyy10.
#8 allnums5
#9 @7 mixedline2 $3.
#10 blankline $ 1.
;
format allnums1 z9.
allnums2 z6.
bigdate mmddyy10.
;
datalines;
111111-911
000111111
000038
NAME OF CITY
2
0
10/31/2007
28
C45
222222-911
000222222
000038
NAME OF CITY
2
0
10/31/2007
28
C46
333333-911
000333333
000038
NAME OF CITY
2
0
10/31/2007
28
C47
;
run;
proc print;
run;
Jerry, best of luck reading that odd data set into SAS!
I hope that this suggestion proves helpful now, and in the future!
Of course, all of these opinions and insights are my own, and do not
reflect those of my organization or my associates. All SAS code and/or
methodologies specified in this posting are for illustrative purposes
only and no warranty is stated or implied as to their accuracy or
applicability. People deciding to use information in this posting do so
at their own risk.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Michael A. Raithel
"The man who wrote the book on performance"
E-mail: MichaelRaithel@westat.com
Author: Tuning SAS Applications in the MVS Environment
Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
Second Edition
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172
Author: The Complete Guide to SAS Indexes
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ice is forming on the tips of my wings
Unheeded warnings. I thought I thought of everything - Pink Floyd
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++