BookmarkSubscribeRSS Feed
kmcp
Calcite | Level 5
I run a program every weekday that pulls new data from the past 24 hours. So, I want to go back 1 and 31 days Tues-Thurs and 3 and 33 days on Mon. How do I set this up? This is the current code:

%LET DATEC = (CURRENT DATE - 31 DAYS);
%LET STARTQT = (CURRENT DATE - 1 DAYS);

When I have run the program the past two Mondays, I have manually changed the 31 and 1 to 33 and 3.

Thanks for your help!
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Look at using the INTNX function in your code.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

intnx function site:sas.com

using sas dates intnx site:sas.com
polingjw
Quartz | Level 8
In addition to the intnx function, you could also use the weekday function. For example:

%let weekday=%sysfunc(weekday(%sysfunc(today())));

If you create the macro variable weekday as above, it will have a value of 2 every Monday. Conditional logic could then be used to determine which date variables to use.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 4185 views
  • 0 likes
  • 4 in conversation