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.);
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.
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.