0
votes

I want to create dates that will automatically be calculated by SAS based on the current date. The dates that I want to calculate are:

The next quarter in the format of YYQ (e.g. 161)
The current year in the format YYYY (e.g. 2015)
The Saturday before the previous Saturday in the format DDMMMYYYY (e.g. 24OCT2015)
The previous Friday in the format DDMMMYYYY (e.g. 30OCT2015)
The first day of the current quarter in the format DDMMMYYYY (e.g. 01OCT2015)
The first day of the current month in the format DDMMMYYYY (e.g. 01OCT2015)
The last day of the current month in the format DDMMMYYYY (e.g. 31OCT2015)

1
So what's your question? This is not a coding service, please post what you've tried. A hint is look at the INTNX function. - Reeza

1 Answers

2
votes

Next Quarter

qtr = intnx('quarter',date(),1);
format qtr yyqn4.;

Current Year

year = date();
format year year4.;

Saturday before Previous Saturday

sat = intnx('week.7',date(),-2);
format sat date9.;

Previous Friday

fri = intnx('week.6',date(),-1);
format fri date9.;

First Day of Current Quarter

qstart = intnx('quarter',date(),0);
format qstart date9.;

First Day of Current Month

mstart = intnx('month',date(),0);
format mstart date9.;

Last Day of Current Month

mend = intnx('month',date(),0,'end');
format mend date9.;