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.

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
  • 3 replies
  • 4003 views
  • 0 likes
  • 4 in conversation