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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3975 views
  • 0 likes
  • 4 in conversation