DATA Step, Macro, Functions and more

Macro Issues with %Mend

Reply
New Contributor
Posts: 2

Macro Issues with %Mend

Hey Guys,
I'm consistently getting the following error: Macro keyword MEND appears as text. A semicolon or other delimiter may be missing.

I can get the macro to run by submitting the following string a few times:

*'; *"; *); */; %mend; run;

although once the macro has compiled, it produces a recursive reference error for the variable CLUST. IF someone would be willing to look at my code and let me know what they think is going wrong that would be great!

Cheers,
Ashton

%macro clusfinal (data = , clust=) ;
data clusdat1;
set &data;
if cluster ne &clust then mean1 = "."; run;
proc arima data = clusdat1;
identify var = mean1 (1);
run;
estimate p = 1 outest = autoclus'&clust' ;
RUN;
proc print data = autoclus;
run;
%mend;

%clusfinal (data = clusdata, clust =1);
Super Contributor
Super Contributor
Posts: 3,174

Re: Macro Issues with %Mend

You need to share your SAS code execution (and compilation) as part of a complete SAS log, not just the code-piece you might think is related. Ensure that all code (including macros and macro variables) are revealed - such as using:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC MPRINT;

In fact, this additional level of diagnostics may help you with desk-checking the code execution for culprit like open comment or missing semi-colon.

Scott Barry
SBBWorks, Inc.
Trusted Advisor
Posts: 2,113

Re: Macro Issues with %Mend

For this line,

estimate p = 1 outest = autoclus'&clust' ;

you need to use double-quotes (") to get it to resolve to

estimate p = 1 outest = autoclus1;
New Contributor
Posts: 2

Re: Macro Issues with %Mend

Thanks guys! got it resolved with the change from single quotes to doubles. Appreciate the help.

-A
Ask a Question
Discussion stats
  • 3 replies
  • 149 views
  • 0 likes
  • 3 in conversation