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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 32883 views
  • 7 likes
  • 2 in conversation