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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 4638 views
  • 0 likes
  • 4 in conversation