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

I am struggling to use macro variables within a macro.

 

For example:

 

%LET Run_dt = 31Mar2019;

%LET Report=%SYSFUNC(INTNX(MONTH,"&run_dt."d,0,e),DATE9.);

%LET start=%SYSFUNC(INTNX(MONTH,"&run_dt."d,-11,e),DATE9.);

%put &Report. &start.;

 

The Log will show

 

31MAR2019 30APR2018

 

But I would like to do this within a Macro (there will be part of something larger within the macro I'm not doing it without reason :))

 

Like this;

 

%Macro wont_work;

%LET Report=%SYSFUNC(INTNX(MONTH,"&run_dt."d,0,e),DATE9.);

%LET start=%SYSFUNC(INTNX(MONTH,"&run_dt."d,-11,e),DATE9.);

%Mend wont_work;

 

%month_prov;

 

This as I'm sure you know doesn't give me the results I want!

 

Please can someone explain my error to me?

 

Thankyou!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Make these two macro variable Global .

 

%LET Run_dt = 31Mar2019;

%Macro wont_work;
%global Report start ;
%LET Report=%SYSFUNC(INTNX(MONTH,"&run_dt."d,0,e),DATE9.);
%LET start=%SYSFUNC(INTNX(MONTH,"&run_dt."d,-11,e),DATE9.);
%Mend wont_work;

 

%wont_work

%put &Report. &start.;

View solution in original post

2 REPLIES 2
Ksharp
Super User

Make these two macro variable Global .

 

%LET Run_dt = 31Mar2019;

%Macro wont_work;
%global Report start ;
%LET Report=%SYSFUNC(INTNX(MONTH,"&run_dt."d,0,e),DATE9.);
%LET start=%SYSFUNC(INTNX(MONTH,"&run_dt."d,-11,e),DATE9.);
%Mend wont_work;

 

%wont_work

%put &Report. &start.;
mauley
Fluorite | Level 6

ThankYou! Makes sense ! 🙂