Which title statement will be printed as a result of the SAS code shown below?
Listing of MTEST Macro VariablesListing of Macro Variables Listing of GLOBAL Macro VariablesListing of &val3 Macro VariablesThere is no title because the code produces an error in the log.
According to me Local symbol table has Va13=MTEST macro variable once it finishes execution local symbol table gets deleted and only global symbol table remains so The correct ans would be " Listing of GLOBAL Macro Variables "??
Hi,
As you mentioned Local symbol table has val3=MTEST and the scope variable in proc print will be having the scope of MTEST only , not GLOBAL because the global macro variable will be overwritten with local macro variable if it is with same name..I took a sample data and checked which might help you.
%let val3=GLOBAL;
data test;
input var $ scope $;
cards;
var1 LOCAL
var2 GLOBAL
var3 LOCAL
;
run;
options symbolgen;
%macro mtest(val1,val2,val3=MTEST);
title "Listing of &val3 Macro Variables";
proc print data=&val1;
where scope="&val3";
Var &val2;
run;
%mend;
%mtest(test,var); /* This macro returns val3=MTEST only */
%mtest(test,var,val3=&val3); /* here i have declared val3 will take the global macro variable value as GLOBAL */
PLease find the snapshot for the below macro output.
Hi,
As you mentioned Local symbol table has val3=MTEST and the scope variable in proc print will be having the scope of MTEST only , not GLOBAL because the global macro variable will be overwritten with local macro variable if it is with same name..I took a sample data and checked which might help you.
%let val3=GLOBAL;
data test;
input var $ scope $;
cards;
var1 LOCAL
var2 GLOBAL
var3 LOCAL
;
run;
options symbolgen;
%macro mtest(val1,val2,val3=MTEST);
title "Listing of &val3 Macro Variables";
proc print data=&val1;
where scope="&val3";
Var &val2;
run;
%mend;
%mtest(test,var); /* This macro returns val3=MTEST only */
%mtest(test,var,val3=&val3); /* here i have declared val3 will take the global macro variable value as GLOBAL */
PLease find the snapshot for the below macro output.
Thank you Vish33 very much, I have exam tomorrow I was lil confuse with that question.
welcome Poo..All the best
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.