DATA Step, Macro, Functions and more

INTNX within macro var definition

Reply
Frequent Contributor
Frequent Contributor
Posts: 76

INTNX within macro var definition

Could someone explain why this doesn't work and how to make it work. (other than a call symput from a data step)

%let history_end_date = 01Jul2009;
%let val1 = %sysfunc(inputn(&HISTORY_END_DATE,date9.));
(This is ok up to this point); val1 = 18079;

However, neither of these statements work....

%let val2a = %sysfunc(intnx("Month",18079,1,"Begin"));
%let val2b = %sysfunc(intnx("Month",%eval(&val1),1,"Begin"));


Thanks
Frequent Contributor
Frequent Contributor
Posts: 76

Re: INTNX within macro var definition

Never mind - I got it working by removing the quotes aroung month and begin. Quotes and macros have gotten me before. Could somebody explain why they are not needed in this instance.

Fix:

%let history_end_date = 01Jul2009;
%let val1 = %sysfunc(inputn(&HISTORY_END_DATE,date9.));
%let val2b = %sysfunc(intnx(Month,%eval(&val1),1,Begin));

* no quotes needed
Super Contributor
Super Contributor
Posts: 3,174

Re: INTNX within macro var definition

When working with a DATA step and a function, you are either specifying a constant string (in quotes or double-quotes), and when using the macro %SYSFUNC interface (as well as macro language constructs), the data values themselves are treated as data-strings, unless you are using a macro variable (with an ampersand prefix).

Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: INTNX within macro var definition

Correction (truncated info): "When working with a DATA step and using a function, you specify one or argument(s) as string constant (in quotes or double-quotes) and/or one or more SAS variables, and ...".

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 159 views
  • 0 likes
  • 2 in conversation