SAS folks- I've been playing around with this for quite awhile, and need some help. A colleague has lots of txt files in a directory, and is trying to read them with SAS. The filename includes the date. Unfortunately, they have a little twist that I have so far been unable to unravel - the data we want starts on line 7, is multiple (unknown) records per line, and -9999 is null data and does not need to be read. I have no problem inputting one file in the infile statement. This reads the multiple values per line, kicks out the null data, and I am able to pull out the date from the filename. DATA STRANGEDATA ; LENGTH MYINFILE $ 99 ; INFILE 'X:\ES\EA\Wildlife\2000\abc20000601.txt' FILENAME=MYINFILE FIRSTOBS=7 LRECL=35000 PAD ; INPUT DEPTH @@ ; IF DEPTH > 0 ; SAVEFILE=MYINFILE ; Y=COMPRESS(SAVEFILE,,'DK') ; SASDATE=MDY(SUBSTR(Y,9,2), SUBSTR(Y,11,2), SUBSTR(Y,5,4)) ; FORMAT SASDATE DATE9. ; OUTPUT ; RUN; However, when I change the filename to include a wildcard, I can't stop it reading the first 6 lines of subsequent files. I've been fooling around with EOV= but can't seem to make it work. INFILE 'X:\ES\EA\Wildlife\2000\abc*.txt' FILENAME=MYINFILE FIRSTOBS=7 LRECL=35000 PAD ; So, I went at it from another method - making a file with the filenames, and reading the files in turn. This successfully picks up all the files in the list, but only the first entry on a line. x 'del index.lst'; x 'dir /b X:\ES\EA\Wildlife\2000\abc*.txt > index.lst'; x 'exit' ; DATA STRANGEDATA ; LENGTH MYINFILE $99 ; INFILE 'index.lst' PAD MISSOVER; INPUT MYINFILE $ 1-30; FULLFILE='X:\ES\EA\Wildlife\2000\'||MYINFILE ; INFILE FILE FILEVAR=FULLFILE END=DONE PAD MISSOVER FIRSTOBS=7 LRECL=35000; DO UNTIL (DONE); INPUT DEPTH ; IF DEPTH > 0 ; Y=COMPRESS(MYINFILE, , 'DK'); SASDATE=MDY(SUBSTR(Y,5,2), SUBSTR(Y,7,2), SUBSTR(Y,1,4)) ; FORMAT SASDATE DATE9. ; OUTPUT; END; RUN ; Adding @@ to the INPUT and deleting MISSOVER from INFILE to pick up the multiple occurrences per line gets nothing, and I know there should be observations from running the files separately. I have to be missing something obvious here - any help you can give me would be much appreciated. Three of the many files are attached here. Thanks for any help you can give me! We are running 9.2 on Windows. WendyT
... View more