We need to get a dynamic date value for every Monday. The code We have been trying is as below.
%let todaysDate=%sysfunc(intnx(week.2,%sysfunc(inputn(01042019,ddmmyyn8.)),1,b)) ;
%put &todaysDate.;
The result I am getting is as below.
GOPTIONS ACCESSIBLE;%let todaysDate=%sysfunc(intnx(week.2,%sysfunc(inputn(01042019,ddmmyyn8.)),1,b)) ;
%put &todaysDate.;
SYMBOLGEN: Macro variable TODAYSDATE resolves to 1042023
1042023
Here the doubt is why Year value is changing instead Date value.
Please clarify us and give us a solution for it.
Bunch of Thanks in Advance !! 🙂
%let todaysDate=%sysfunc(intnx(week.2,%sysfunc(inputn(01042019,ddmmyy8.)),1,b),date9.) ;
%put &todaysDate.;
Thank you for your quick response 🙂 @Ksharp . Is there any specific reason that the code which I was trying not working?.
Instead of using inputn(01042019,ddmmyyn8.)
Use the automatic macrovar &SYSDATE9, as in
inputn(&sysdate9,date9.)
Then you can generate 1 week.2 forward with
%let todaysDate=%sysfunc(intnx(week.2,%sysfunc(inputn(&sysdate9,date9.)),1,b),date9.);
%put &=todaysdate;
which today (4/5/2019) generates 08APR2019.
Change the rightmost format to your preference.
There is no informat with that name, so it is just returning 1,042,019 as the date. That is in the year 4812.
To convert 01042019 to a date us the DDMMYY informat.
Thanks to everyone for your response and solution also.
Here we have an another doubt,
We have weekly loads on every Monday with the time stamp in file name (say- Base_01042019.csv).
We need to read the file names by giving dynamic date values.
Here, if I give the below codes then It will refer every coming Monday date, then the file will not be available.
Please suggest me in this case how can we read the files with out the job gets fail.
@Lakshmi_G90 wrote:
Thanks to everyone for your response and solution also.
Here we have an another doubt,
We have weekly loads on every Monday with the time stamp in file name (say- Base_01042019.csv).
We need to read the file names by giving dynamic date values.
Here, if I give the below codes then It will refer every coming Monday date, then the file will not be available.
Please suggest me in this case how can we read the files with out the job gets fail.
Need more details. You can also get a list of files from a directory and find all files after a specific date or use the modified/created date from the metadata. Check the SAS Macro Appendix for an example of how get a list of files.
Thanks to Everyone for your support and suggestions.
We fulfilled our requirement with your support successfully. 🙂
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.