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

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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