|
input@1 @; /* -------------------------->new statement,read the infile
and hold it.*/
if compress(_infile_)='' then delete; /*to check if it is a emptyline,
if so then delete*/
else /*else input next 9 lines*/
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.
; /*the 10 th line is not needed*/
HTH
Yu
On Nov 9, 2007 12:24 PM, Jerry L Diebal <jdiebal@gmail.com> wrote:
> Thanks to everyone who responed. The solutions from Wei, Mary, Michael, and
> Masuod all seem to work fine except for the problem with the my infile not
> ending with a blank line. Unless I manually put in a blank line the log
> shows that i have a "LOST CARD" and the last record is skipped. So the
> infile is 10 lines for every record but sometimes that last record doesn't
> have a blank line. Since this will have to be automated and I have no
> control over the the last line problem does anyone know a workaround so it
> will work whether or not a blank line ends the file?
>
>
>
>
> On 11/8/07, Michael Raithel <michaelraithel@westat.com> wrote:
> >
> > 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
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
>
|