I am trying to import 1 file name on Mondays and another file name on Tue-Fridays.
For example, on Monday I want to import the file from Saturday but on Tue-Fri I want to import the file for the current day.
This is what I am trying. It doesn't seem to read the &today macro at all.
Code:
%let today=%sysfunc(putn(%sysfunc(date()),yymmddn8.));
%let today2=%sysfunc(PUTN(%eval(%sysfunc(date()) - 2), yymmddn8.));
%macro setdate(date);
%let date= weekday(today());
%if &date = 2 %then
%do;
proc import out=M_IMPORT
datafile="<path>/test/M_Daily_Admissions_&today2..csv"
dbms=csv replace;
datarow=2;
getnames=no;
run;
%end;
%else %if &date <> 2 %then
%do;
proc import out=M_IMPORT
datafile="/<path>/test/M_Daily_Admissions_&today..csv"
dbms=csv replace;
datarow=2;
getnames=no;
run;
%end;
%mend setdate;
This might not cover everything, but it's the right place to start. This statement doesn't do what you expect:
%let date= weekday(today());
While it runs without error, it assigns &DATE a 16-character value (the exact characters you see to the right of the equal sign, with no functions being executed).
As you did in several earlier cases, you need to apply %SYSFUNC to get macro language to carry out DATA step functions:
%let date = %sysfunc(weekday(%sysfunc(today())));
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.