09-09-2015 09:07 PM
I can't find the post that I originally used so I can cite the programmer but someone on the site helped me create a pipe that allows the files to be imported sequentially. The reason I need that is because later files could be making corrections on earlier abstracts so the newer file data must be the row of data used when looking at multiples of the same abstract.
This worked well before because the files are named sequentially i.e. C001, C002 etc. But now the company is using a new software program so there will be files with the same file name so I need to now sequence by file date.
Previous code looked like this:
FILENAME FILES PIPE "DIR F:\TEST\TEST_FILES\*.TXT /B /O:N"; Data Have; INFILE FILES TRUNCOVER END=LAST; INPUT FNAME $250.; FNAME="F:\TEST\TEST_FILES\"||Trim(Left(FNAME)); run;
The the data extraction looks like this (I won't list all fields):
Data DataA; set Have; INFILE IN FILEVAR=FNAME END=EOF LRECL=5000 Truncover firstobs=2; Do Until (EOF); input @1 Field1 $1.
So how do I now change it so the "Have" is also including the date of the file? Or sequence by date and add another sequencial number to the file name? Thanks for any and all assistance.
09-10-2015 05:13 AM
I just fiddled around with the DOS (what a fitting acronym!) dir command, and sadly, it does not provide an option for getting exactly the output you need.
So you will have to use it without the /b option and parse the output, as it contains lines you don't want which need to be discarded, and you need to read the columns correctly.
OTOH, the output of dir is at least formatted in a consistent way that allows formatted input with column prefixes.
09-10-2015 11:06 AM
I believe that the DIR switch /O will sort the pipe output with oldest first and /O:-D by newest first if that helps. BUT you will need to remove the /B (bare) for dates to display and parse the output.
The /T switch control which time field is displayed or used. /T:C would use creation and /T:W last writtend
09-10-2015 11:36 AM
Thanks for your responses. I'll check out your suggestions and see what I can come up with. The code I have already uses /O so maybe it is sorting in that order and not in number order as I assumed.