Hello,
I have the following files which are generated daily from another system which is date and time stamped.
I have a SAS process which is required to read in these daily files.
I have set up a macro variable so that it creates the date with the last business day %let file_date_m = &file_date_yr.&file_date_mth.&file_date_day.;
As for the time, I would not know when it will be generated, my question is, how can I find the correct file for SAS to read in and can the time part be omitted ?
I would like to set up a macro variable like this (%let cdsfilename = "CDSALL0E_&file_date_m._&time.csv"n;) so that I can read in the correct file depending on the business day.
These files are being read in via PC Files Server.
Examples of the filenames:
CDSALL_20150810_081411.csv
CDSALL_20150811_073451.csv
CDSALL_20150812_072431.csv
CDSALL_20150813_080519.csv
CDSALL_20150814_075526.csv
CDSALL_20150817_080139.csv
CDSALL_20150818_071141.csv
CDSALL_20150819_082730.csv
Thank you.
Execution time may be your bigger concern.
You can create a fileref with the name and date stem and ignore the time part using OS filesystem wildcards. In window.
Filename Input "c:\path\CDSALL_20150810_*.csv"; or use in an infile statement directly.
I am a tad concerned about this:
"CDSALL0E_&file_date_m._&time.csv"n
as you show an _m that does not appear in your input file name examples. Also the "n makes me think you are attempting to make a SAS variable name as most external file operations.
If you show some of the code how your are attempting to use the filename macro variable we might be able to provide some additional details.
You may be able to use a wild card in a FILEREF. Consider the following example which create some files using the names you show and then reads the one from TODAY()-2.
Why are you using PC FILES SERVER? Does that mean that the actually machine that SAS is running on cannot see the files? Because there should not be any other reason you need it since you can read a CSV file with BASE/SAS data step.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.