11-24-2015 10:48 AM
10 or less files comes to directory /abc/landing with timestamp everyday. filenames are like a_yyyymmddhhmmss.dat, b_yyyymmddhhmmss.dat etc.,
sometimes there is a possibility of duplication of files with same content with different different timestamp for sameday. need to select latest time stamped file.
1)if 10 distinct files are there in /abc/landing/ , read all files to convert into SAS data sets.
2)if there are less than 10 files, create a subdirectory withtimestamp from filenames under /abc/landing, /abc/landing/withtimestamp keep those less numbered files into this /abc/landing/withtimestamp and wait and check the /abc/landing untill you get a remaining files with same timestamp.
3)should look /abc/landing everyday to process 10 distinct files available with same dated ones. if there are more than 10 files, should look for a) are there any duplicated files? if so, select 10 distinct files with latest timestamp b) are there any old dated files there. if there are any old dated files send them to respective dated folder and look in that respective folder enough 10 files are there to read those 10 files and delete that respective date directory.
Any documentation or papers links avilable appreciated. Thanks.
11-24-2015 10:57 AM
I'm not sure what type of operating system you are using, but I know using the FILENAME with a PIPE command, you can read files from a directory and create new directories and such. You just need to specify the operating system command (depending on the OS you are on). For example, creating a new directory and then copying and pasting files from one directory to the new directory:
/*** Create new directory ***/ filename f1 pipe 'mkdir "c:\projects\target"'; data _null_; infile f1; input; put _infile_; run; /*** Copy files and paste in new directory ***/ filename f2 pipe 'copy "C:\projects\output" "c:\projects\target"'; data _null_; infile f2; input; put _infile_; run;
12-01-2015 11:56 AM
I would recommend looking into and doing some research on the X or PIPE command inside of SAS. They both allow you to use UNIX code to open and look at files in directories and create new directories and such. I'm sure you could create something that utilized one of those and some SAS language to get what you need.