I need to read many text files from a directory into a one SAS data set.
All the text files have the same varibles but different number of observation.
I've tried to use a wildcard into the INFILE and the program works ok:
DLM=';' DSD missover FIRSTOBS=2;
The problem is that i have to read just since the second observation of every text file (becouse the first one are the titles), and if i use the FIRSTOBS option in the INFILE, it applies just for the first text file, but in the other one it reads all the obs.
Do you know how i could apply the FIRSTOBS =2 in every text file?
When reading with a wild card the files are treated as one stream. There is an option EOV to detect the start of a new file. You could test that variable and use programming logic to skip the first line of the file.
You CAN use FIRSTOBS when reading the files with the FILEVAR option. This requires creating a list of files to be read.
You should consult the documentation regarding the details of these INFILE statement options.
I would be curious to see the result. The way I understand EOV is that it changes from 0 to 1 as soon as it encounters a new file. So reading in more than two files the EOV variable cannot tell you when you start reading in the third file. Or am I wrong?
names a variable that SAS sets to 1 when the first record in a file in a series of
concatenated files is read. The variable is set only after SAS encounters the next
file. Like automatic variables, the EOV= variable is not written to the data set.
Tip: Reset the EOV= variable back to 0 after SAS encounters each boundary.