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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 241 views
  • 0 likes
  • 2 in conversation