DATA Step, Macro, Functions and more

Question regarding Local symbol table

Accepted Solution Solved
Reply
Occasional Contributor poo
Occasional Contributor
Posts: 10
Accepted Solution

Question regarding Local symbol table

Which title statement will be printed as a result of the SAS code shown below?

a.jpg
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 "??


Accepted Solutions
Solution
‎05-29-2014 03:19 AM
Frequent Contributor
Posts: 117

Re: Question regarding Local symbol table

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.

global.jpg

View solution in original post


All Replies
Solution
‎05-29-2014 03:19 AM
Frequent Contributor
Posts: 117

Re: Question regarding Local symbol table

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.

global.jpg

Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Question regarding Local symbol table

Thank you Vish33 very much, I have exam tomorrow I was lil confuse with that question.

Frequent Contributor
Posts: 117

Re: Question regarding Local symbol table

welcome Poo..All the best

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 282 views
  • 1 like
  • 2 in conversation