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 (November 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 24 Nov 2003 10:01:36 -0500
Reply-To:     Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject:      Re: Firstobs option ignored with multiple file read
Comments: To: mcmillan@IARC.FR
Content-Type: text/plain; charset=ISO-8859-1

On Mon, 24 Nov 2003 05:18:41 -0800, G.McMillan <mcmillan@IARC.FR> wrote:

>Greetings! >I am using a wildcard in the infile statement to read a number of text >files. The first line of each text file lists the column names, and I >want to skip over these. In principal, the ‘firstobs=' option in the >infile statement would accomplish this. However, SAS v8.2 only >respects the ‘firstobs=' option for the first file read, and ignores >it for each subsequent file. The result is that SAS reads the first >line of each text file after the first, resulting in invalid data >errors for each of the numeric variables (since it is trying to read >column names as numbers!). > >I appreciate any thoughts on this problem. > >Thanks very much in advance! >GM > > >The code is shown below (note the ‘*' wildcard in the file >specification): > >Data WORK.X; > infile "E:\Users\Lymphoma - *.txt" >delimiter='09'x MISSOVER DSD lrecl=32767 firstobs = 2; > >informat No_hospital $2. ; >informat No_Patient best32. ; > >format No_hospital $2. ; >format No_Patient best12. ; > >input > No_hopital $ > No_Patient >; >output; >run;

The infile statement has option filename= that provides the name of the file in the current buffer. When that changes, skip. Like: >Data WORK.X; length filenam $200; /*ensure enough space for path/filename */ > infile "E:\Users\Lymphoma - *.txt" > delimiter='09'x MISSOVER DSD lrecl=32767 /*firstobs = 2 suppressed, because it's dealt with by code*/ filename = filenam /* collect current path/file name */ ; input @; /* load buffer */ if filenam ne lag(filenam) then input; ** skipping header; > >informat No_hospital $2. ; >informat No_Patient best32. ; > >format No_hospital $2. ; >format No_Patient best12. ; > >input > No_hopital $ > No_Patient >; >output; >run;

Good Luck Peter Crawford


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