BookmarkSubscribeRSS Feed
Lakshmi_G90
Calcite | Level 5

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 !! 🙂

7 REPLIES 7
Ksharp
Super User

%let todaysDate=%sysfunc(intnx(week.2,%sysfunc(inputn(01042019,ddmmyy8.)),1,b),date9.) ;
%put &todaysDate.;
Lakshmi_G90
Calcite | Level 5

Thank you for your quick response 🙂  @Ksharp . Is there any specific reason that the code which I was trying not working?. 

 

 

mkeintz
PROC Star

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.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Tom
Super User Tom
Super User

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.

Lakshmi_G90
Calcite | Level 5

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.

Reeza
Super User

@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.

Lakshmi_G90
Calcite | Level 5

Thanks to Everyone for your support and suggestions.

We fulfilled our requirement with your support successfully. 🙂

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 1546 views
  • 0 likes
  • 5 in conversation