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

Hi ,

I have a requirement in SAS DI where I need to create dates like

2 months before the current date

3 months before the current date

4 months before the current date

Can some one provide me the way to derive these dates based on the system date.

Thanks,Ashish

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

How about something like this:

%let month_back2 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 2, SAME), date9.);

%let month_back3 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 3, SAME), date9.);

%let month_back4 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 4, SAME), date9.);

%put month_back2 = &month_back2;

%put month_back3 = &month_back3;

%put month_back4 = &month_back4;

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

How about something like this:

%let month_back2 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 2, SAME), date9.);

%let month_back3 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 3, SAME), date9.);

%let month_back4 = %sysfunc(intnx(MONTH, "&sysdate9."d, - 4, SAME), date9.);

%put month_back2 = &month_back2;

%put month_back3 = &month_back3;

%put month_back4 = &month_back4;

sabooalex
Calcite | Level 5

Hi,

Thanks for getting back to me,much appreciated!

So I will copy this in the precode of the job, and it should work.

One last thing on this question,can the same not be done by using the parameters tab of the job or one has to write this code manually?

Thanks,Ashish

LinusH
Tourmaline | Level 20

in my mind, parameters are usfell when connection to job using a data set as a control table, and the loop transform.

You could use parameters, but I can't see the benefit in your case.

Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1149 views
  • 6 likes
  • 3 in conversation