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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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