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
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
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.
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
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
Thank you so much for providing the solution.
Thanks
Chandan Mishra
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.