Help using Base SAS procedures

using macro variables for INTNX function

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

using macro variables for INTNX function

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?


Accepted Solutions
Solution
‎10-19-2011 08:25 PM
Super User
Super User
Posts: 7,078

using macro variables for INTNX function

Posted in reply to willy0625

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


All Replies
Solution
‎10-19-2011 08:25 PM
Super User
Super User
Posts: 7,078

using macro variables for INTNX function

Posted in reply to willy0625

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 10234 views
  • 1 like
  • 2 in conversation