BookmarkSubscribeRSS Feed
khamsies
Calcite | Level 5

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;

1 REPLY 1
Astounding
PROC Star

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())));

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 564 views
  • 0 likes
  • 2 in conversation