Hi @heatherml20, I noticed that you're missing semicolons after some of your %PUT statements.
%put &=First
That can cause the errors you're encountering. Try going through your code, add all of the required semicolons to end each statement and rerun.
Usually you don't need to delete macro variables. They will disappear when your current SAS session ends. But to delete macro variable just list its name in the %SYMDEL statement.
%symdel x;
To see what is in the GLOBAL symbol table you can use special keyword _GLOBAL_ with the %PUT statement.
%put _global_;
Example::
1 %let x=101; 2 %let y=102; 3 %put _global_; GLOBAL X 101 GLOBAL Y 102 4 %symdel x ; 5 %put _global_; GLOBAL Y 102
To display in the LOG all macro variables stored, you can use a %PUT statement with the keyword _ALL_ to display all macro variables or _USER_ to display user defined macro variables.
%put _all_;
%put _user_;
To delete macro variables created, you can use the %SYMDEL statement with the name of the macro variable:
%symdel <macro_var_name>;
This is how your log would have looked like, had you submitted your code as part of a macro definition (using the macro name test for demonstration):
76 %macro test; 77 %let Fullname=AnTHoNY MilLeR; 78 %Let First=%scan(&fullname, 1); 79 %Let Last=%scan(&fullname, 2); 80 81 %put &=First 82 83 %put %sysfunc(propcase(&First)); ERROR: Macro keyword PUT appears as text. ERROR: A dummy macro will be compiled. 84 85 %put &=Last 86 87 %put %sysfunc(propcase(&Last)); ERROR: Macro keyword PUT appears as text. ...
But you did not show any of the above error messages, which indicates that you did not submit a macro definition and hence don't need a %MEND statement.
Oh yes, you're right. The %MEND statement helps at least in this particular example (as does submitting the two forgotten semicolons) -- but not because it was missing in the first place.
A %MEND statement is also part of the "magic" string that is recommended as a remedy in situations where the reason of the "open code statement recursion" is less obvious. The usage of this string
*'; *"; *); */; %mend; run;
is documented in the section "Solving Open Code Statement Recursion Problems" of the Macro Language Reference, together with other recommendations.
@antonbcristina wrote:
Try going through your code, add all of the required semicolons to end each statement and rerun.
... and before you rerun the statements which failed, submit the two missing semicolons alone. This should get the macro processor out of that "statement recursion" mode.
;;
A %MEND statement would end the definition of a SAS macro (starting with a %MACRO statement -- which is neither shown in your log, nor required for the %LET, %PUT and %SYMDEL statements to work).
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.