BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CHAN07
Calcite | Level 5

Hello 

 

I want to specify folder date in the program. I receive the data on Weekdays at night and run the program early next morning. So, the folder date is always like this:

 

Processing data on Tue        --------------     Date of Mon

Processing data on Wed       --------------    Date of Tue

Processing data on Thur       --------------    Date of Wed

Processing data on Fri          --------------    Date of Thu

Processing data on Mon       --------------    Date of Fri(Last)              /*Facing problem in this one*/

 

I have written macro variable where it reads in the previous data dates. 

 

%LET FOLDER_NAME = %SYSFUNC(INTNX(WEEKDAY, %SYSFUNC(TODAY()),-1,E),YYMMDDN8.);

 

So, If I process the data on 20170725, the folder date would be 20170724. But how should I include logic in this one for processing data on Monday. So, if the data is processed on monday of any given week, it should take in the date of last friday.

 

Thanks

Chandan Mishra

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The alignment parameter is messing up your calculation.

Remove it.

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 59         
 60         %let testdate = '24Jul2017'd;
 61         %LET FOLDER_NAME = %SYSFUNC(INTNX(WEEKDAY, &testdate,-1),YYMMDDN8.);
 62         %put &folder_name.;
 20170721
 63         
 64         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 76    

View solution in original post

4 REPLIES 4
Reeza
Super User

Did you check the output? Using INTNX with the WEEKDAY should accomplish this, is it not? If so, post an example of how it isn't working.

CHAN07
Calcite | Level 5

So, If I used this code for Monday 24th July, 2017, it is giving me value of 20170723. Rather I want the value to be  20170721 i.e. Friday.

 

 

Thanks

Chandan Mishra

 

 

Reeza
Super User

The alignment parameter is messing up your calculation.

Remove it.

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 59         
 60         %let testdate = '24Jul2017'd;
 61         %LET FOLDER_NAME = %SYSFUNC(INTNX(WEEKDAY, &testdate,-1),YYMMDDN8.);
 62         %put &folder_name.;
 20170721
 63         
 64         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 76    
CHAN07
Calcite | Level 5

 Thank you so much for providing the solution. 

 

Thanks

Chandan Mishra

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