Desktop productivity for business analysts and programmers

call a macro inside a macro

Accepted Solution Solved
Reply
Contributor ak2
Contributor
Posts: 34
Accepted Solution

call a macro inside a macro

Hi. I have a macro where I want to do 2 things if n>0 (else do nothing). I want to append a data set to an existing table, and I want to call for another macro. I get this error message referring to the call of the macro: "Statement is not valid or it is used out of proper order." Can anyone help me? 

 

%macro x;


%if &n.>0 %then %do;

proc append base=a data=b;run;
call execute("%addInfo");
%end;

 

%mend;

%x;


Accepted Solutions
Solution
‎02-23-2018 08:15 AM
Respected Advisor
Posts: 3,252

Re: call a macro inside a macro

The call execute is unnecessary here. This ought to work (assuming macro %addinfo is defined).

 

%macro x;
%if &n.>0 %then %do;
proc append base=a data=b;run;
%addInfo
%end;
%mend;

%x

 

--
Paige Miller

View solution in original post


All Replies
Solution
‎02-23-2018 08:15 AM
Respected Advisor
Posts: 3,252

Re: call a macro inside a macro

The call execute is unnecessary here. This ought to work (assuming macro %addinfo is defined).

 

%macro x;
%if &n.>0 %then %do;
proc append base=a data=b;run;
%addInfo
%end;
%mend;

%x

 

--
Paige Miller
Contributor ak2
Contributor
Posts: 34

Re: call a macro inside a macro

Posted in reply to PaigeMiller
Thank you! That worked fine.
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 483 views
  • 0 likes
  • 2 in conversation