BookmarkSubscribeRSS Feed

Hi,

 

I have this part of a SAS Macro

 

%let runmonth=%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.); /*Curr Month*/

%let lastmonth=%sysfunc(intnx(month,%sysfunc(today()),-2),yymmn6.); /*Prev Month*/

%let runmonth2=%sysfunc(intnx(month,%sysfunc(today()),-1),yymmdd10.); /*Curr Month*/

%let HPIDate=%sysfunc(intnx(quarter,"&runmonth."d,0,e),yymmdd10.); /*last month of previous Qtr*/

 

and when I run the HPIDate, I get this error message

 

14 GOPTIONS ACCESSIBLE;

SYMBOLGEN: Macro variable RUNMONTH resolves to 201610

ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.

ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC

or %QSYSFUNC function reference is terminated.

15 %let HPIDate=%sysfunc(intnx(quarter,"&runmonth."d,0,e),yymmdd10.);

16

17 GOPTIONS NOACCESSIBLE;

18 %LET _CLIENTTASKLABEL=;

19 %LET _CLIENTPROJECTPATH=;

20 %LET _CLIENTPROJECTNAME=;

21 %LET _SASPROGRAMFILE=;

22

23 ;*';*";*/;quit;run;

24 ODS _ALL_ CLOSE;

25

26

27 QUIT; RUN;

28

 

How do I get around this please?

 

2 REPLIES 2
Kurt_Bremser
Super User

The literal "201610"d is not a valid date literal. '01oct2016'd would be one.

 

To make your life easier, I recommend to do all the calculations in a data _null_ step and use call symput() to create the macro variables.

 

And when I need a date for reference in a macro variable, I simply use the raw number:

%let runmonth=%sysfunc(today());

Can be used anywhere where a date is needed.

Kurt_Bremser
Super User

To create hpidate, I'd do

data _null_;
runmonth = intnx('month',today(),-1);
hpidate = intnx('quarter',runmonth,-1,'e');
call symput('hpidate',put(hpidate,best.));
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1790 views
  • 1 like
  • 2 in conversation