Solved
New Contributor
Posts: 4

# sas DI studio macro date

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

Accepted Solutions
Solution
‎02-06-2014 08:57 PM
Super User
Posts: 3,257

## Re: sas DI studio macro date

%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;

All Replies
Solution
‎02-06-2014 08:57 PM
Super User
Posts: 3,257

## Re: sas DI studio macro date

%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;

New Contributor
Posts: 4

## Re: sas DI studio macro date

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

Super User
Posts: 5,434

## Re: sas DI studio macro date

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
🔒 This topic is solved and locked.