SAS Advanced Programming for SAS 9 — Question 33
The following SAS program is submitted:
%let a=cat;
%macro animal(a=frog);
%let a=bird;
%mend;
%animal(a=pig)
%put a is &a
What is written to the SAS log?
Answer options
- A. a is pig
- B. a set cat
- C. a is frog
- D. a is bird
Correct answer: B
Explanation
The macro variable 'a' is set to 'cat' before the macro is called. Inside the macro, a local variable 'a' is created, but it does not affect the global variable 'a'. Therefore, when %put is executed, it retrieves the value of the global variable 'a', which remains 'cat', resulting in 'a set cat'. The other options do not reflect the actual value of 'a' after the macro execution.