Hello SAS users
%LET dateend=SYSDATE9;
%LET newday=%SYSFUNC(INTNX('day',"&dateend"d,-1));
I set the first macro variable called dateend to be the current date, then
I would like to set the macro variable called newday to be the previous day.
So for example, If I ran this now, I would expect
dateend=20OCT2011
newday=19OCT2011.
Please note, I am trying to run these codes outside %macro-%mend block, but as just single lines, and they are under any datasets.
At the moment, SAS is not happy with what I am doing and I have tried the second line without %SYSFUNC but it still wouldn't work.
Would anyone have any idea?
You are missing an ampersand in the first %LET statement.
Also you do not use quotes around character strings in SYSFUNC calls.
What format do you want the NEWDAY variable?
You are currently asking for an integer (number of days since 1/1/1960).
Perhaps you meant to do:
%let dateend=&sysdate9.;
%let newday=%sysfunc(intnx(day,"&dateend"d,-1),date9.);
Or better still if you are like me and sometimes leave SAS running interactively for past midnight.
%let dateend=%sysfunc(today(),date9.);
%let newday=%sysfunc(intnx(day,"&dateend"d,-1),date9.);
You are missing an ampersand in the first %LET statement.
Also you do not use quotes around character strings in SYSFUNC calls.
What format do you want the NEWDAY variable?
You are currently asking for an integer (number of days since 1/1/1960).
Perhaps you meant to do:
%let dateend=&sysdate9.;
%let newday=%sysfunc(intnx(day,"&dateend"d,-1),date9.);
Or better still if you are like me and sometimes leave SAS running interactively for past midnight.
%let dateend=%sysfunc(today(),date9.);
%let newday=%sysfunc(intnx(day,"&dateend"d,-1),date9.);
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.