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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.