Thursday, 15 December 2016

Macros interview Questions

1)
%let x=123;
%macro one;
%let x=456;
data one;
y=&x;
run;
proc print data=&syslast;
run;
%put &x;
%mend one;
%one

What will be the value of variable y:
a>123
b>>456
c>_null_
d>none

2)

%macro one(x=123);
%let x=456;
data one;
y=&x;
run;
proc print data=&syslast;
run;
%put &x;
%mend one;
%one(x=789)


What will be the value of variable y:
a>123
b>456
c>_null_
d>789

3)

%macro one(x=123);
data one;
call symputx('x',456);
y=&x;
run;
proc print data=&syslast;
run;
%put &x;
%mend one;
%one(x=789)


What will be the value of variable y:

a>123
b>456
c>_null_
d>789

4)

%let x=890;
%macro one(x=123);
data one;
call symputx('x',456);
y=&x;
run;
proc print data=&syslast;
run;
%put _user_;
%mend one;
%one(x=789)


What will be the value of macro variable in the global symbol table and in the local table:

a>x 123
global x 890

b>x 456
global x 890

c>x 890
global x 456

d>x 789
Global x 890



5)

%let x=890;
%macro one(x=123);
data one;
call symputx('x',456);
y=symget('x');
run;
proc print data=&syslast;
run;
%put _user_;
%mend one;
%one(x=789)

What will be the value of the variable y:

a>890
b>789
c>456
d>123


6)

%let x=890;
%macro one(x=123);
data one;
%global x;
call symputx('x',456);
y=symget('x');
run;
proc print data=&syslast;
run;
%put _user_;
%mend one;
%one(x=789)

What error message you will get in the log window?

a>Attempt to %GLOBAL a name (X) which exists in a local environment.
b>Macro variable x not resolved.
c>The data set WORK.ONE may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
d>Macro compiled but not executed.

7)

%let x=890;
%macro one(x=123);
data one;
%local x;
call symputx('x',456);
y=symget('x');
run;
proc print data=&syslast;
run;
%put _user_;
%mend one;
%one(x=789)

What will be the value of the macro variable x in the local symbol table?
a>890
b>123
c>789
d>456


8)

%let x=890;
%macro one(x=123);
data one;
%local x;
call symputx('x',456,'f');
y=symget('x');
run;
proc print data=&syslast;
run;
%put _user_;
%mend one;
%one(x=789)

What will be the value of the macro variable x in the local symbol table?

a>890
b>123
c>789
d>456

9)
Into clause in the Sql is used to create the macro variable during :
a>Word Scanning time
b>Compilation time
c>Execution time
d>All

10)

%let x=12;
%let y=x;
%let z=y;

%let z=&&&z;


What is the value of the macro variable z;

a>12
b>x
c>y
d>&&&z


11) Which information is not printed by Mlogic option in the SAS Log:

a>Macro initialization
b>Parameter Values
d>Result of arithmetic and logical information
e>data step execution

12)
Macro variable created by the parameters are :
a>global in scope
b>>local in scope
c>Both local and global in scope
d>None of the above

13)What are the rules of creating and updating macro variables?

a>searches in the local table and if present then update>searches in the global table and if present then update> if not present in the global table then create in the local table.


b>searches in the global table and if present then update>searches in the local table and if present then update> if not present in the global table then create in the local table.


c>searches in the global table and if present then update

d>searches in the local table and if present then update



14)
What are the rules for resolving macro variables?
a>Searches in both local and global symbol table at a time

b>Does macro variable present in the local table,if present then retrieve> does macro vraible present in the global symbol table>warning:Apperent symbolic reference macvar not resolved

 c>does macro variable present in the global symbol table>Does macro variable present in the local table,if present then retrieve>warning:Apperent symbolic reference macvar not resolved

d>ALL



15)


%let x=0;
%macro outer;
%local x;
%let x=1;
%inner
%mend outer;
%macro inner;
%local y;
%let y=&x;
%mend inner;


What will be the value of the macro variable in the Global Symbol table?

a>y
b>0
c>1
d>&x


16) Which Statement is false?

a>%do and %end statements are valid only inside a macro defination.

b>index variable in the %do loop is a macro variable

c>Index variable is created in the global symbol table if it does not already exist in another symbol table.

d>The %by clause is optional in the %do loop.



17)Which statement is true regarding the macro variables:

a>Always created in global symbol table.
b>Always created in the local symbol table.
c>Always created both in local symbol table and the alocal symbol table.
d>None of the above.

18)
Which option is used to create macro variable in the permanent library:
a>mcompilenote
b>mlogic
c>mstored sasmstore
d>mprint 




1.b 2.b 3.d 4.d 5.c 6.a 7.d 8.(Please explain significance of 'f' in Call symputx)
10.a 11. e 12.b 13 a 14.b 15.b 16.a 17.a 18.c

No comments:

Post a Comment