36. The following SAS program is submitted:
%macro one(input);
%two;
%put the value is &date;
%mend;
%macro two;
data _null_;
call symput('date', '12SEP2008');
run;
%mend;
%let date=31DEC2006;
%one(&date)
What is the result when the %PUT statement executes?
A. A macro variable DATE with the value 12SEP2008 is retrieved from the local symbol table for the
ONE macro
B. A macro variable DATE with the value 12SEP2008 is retrieved from the local symbol table for the
TWO macro
C. A macro variable DATE with the value 12SEP2008 is retrieved from the global symbol table
D. A macro variable DATE with the value 31DEC2006 is retrieved from the global symbol table
정답 : C
해설 : 우선 밑에선 두번째 줄로 인해서 date에는 '31DEC2006'라는 값이 할당되었습니다. 그 다음 one(&date)문을 받아서, 생성된 Macro인 one으로 가보죠. Macro one으로 가니 바로 %two로 참조하네요. two에는 call symput('date', '12SEP2008') 문을 통해 변수 date에 글로벌 값 '12SEP2008'을 할당합니다. SYMPUT은 매크로 변수를 글로벌 값으로 할당해줍니다. 즉 글로벌 테이블에는 date변수, '12SEP2008'값이 있겠네요.
37. The following SAS program is submitted:
%let dept=prod;
%let prod=merchandise;
The following message is written to the SAS log:
The value is "merchandise"
Which SAS System option writes this message to the SAS log?
A. %put the value is "&&&dept";
B. %put the value is "&&&dept";
C. %put the value is "&&&dept";
D. %put the value is %quote(&&&dept);
정답 : A
해설 : &를 사용한 포인터 참조 문제입니다. 저도 많이 어려웠던 유형인데요, &dept-> prod 이므로,
&& (prod)는 Merchandaise이므로 정답은 A입니다. 보기 A,B,C가 동일한데 어쨌든 정답은 "&&&dept"라고 씁니다. 이는 Foward Re-Scan Rule 때문이넫요, &기호가 여러번 등장하면 프로세서는 &&두 개를 한 개로 취급합니다. (교재347p 참고)
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.