7. Which one of the following programs contains a syntax error?
A. proc sql;
select product.*, cost.unitcost, sales.quantity
from product p, cost c, sales s
where p.item = c.item and p.item = s.item;
quit;
B. proc sql;
select product.*, cost.unitcost, sales.quantity
from product, cost, sales
where product.item = cost.item and product.item = sales.item;
quit;
C. proc sql;
select p.*, c.unitcost, s.quantity
from product as p, cost as c, sales as s
where p.item = c.item and p.item = s.item;
quit;
D. proc sql;
select p.*, c.unitcost, s.quantity
from product, cost, sales
where product.item = cost.item and product.item = sales.item;
quit;
8. The following SAS code is submitted:
%macro houses(dsn = houses, sub = RANCH);
data &dsn;
set sasuser.houses;
if style = "&sub";
run;
%mend;
%houses(sub = SPLIT)
%houses(dsn = ranch)
%houses(sub = TWOSTORY)
Which one of the following is the value of the automatic macro variable SYSLAST?
A. work.ranch
B. work.houses
C. WORK.RANCH
D. WORK.HOUSES
[정답]D
[풀이]
%macro xxx(yyy): 매크로 변수 yyy를 가지는 매크로 xxx를 생성.
&xxx: 매크로 xxx를 출력
SYSLAST: SAS Statement가 실행됨에 따라 자동적으로 변하는 매크로 변수로, 가장 최근에 생성된 SAS DATASET의 이름을 libref.name형식으로 불러옵니다.생성된 Dataset이 없을 경우, _NULL_값을 불러옵니다.
항상 capital letters로 저장되고, %house(sub=TWOSTORY)는 아래와 같습니다.
data houses;
set sasuser.houses;
if style="TWOSTORY";
run;
9. Given the following SAS data sets
ONE and TWO:
ONE TWO
NUM COUNTRY NUM CITY
______________ ______________
1 CANADA 3 BERLIN
2 FRANCE 5 TOKYO
3 GERMANY
4 BELGIUM
5 JAPAN
The following SAS program is submitted:
proc sql;
select country
from one where not exists
(select * from two where one.num = two.num);
quit;
Which one of the following reports is generated?
A. COUNTRY
GERMANY
JAPAN
B. COUNTRY
FRANCE
BELGIUM
C. COUNTRY
CANADA
FRANCE
BELGIUM
D. COUNTRY
CANADA
FRANCE
GERMANY
[정답] C
[풀이]
where not exists으로
one테이블의 num과 two테이블의 num이 같지 않은 country를 선택(select)하였습니다.
one 테이블과 two테이블의 num이 같지 않은 country는 canada, france, belgium으로 정답은 C입니다.
10. Which one of the following statements is true?
A. The WHERE statement can be executed conditionally as part of an IF statement.
B. The WHERE statement selects observations before they are brought into the PDV.
C. The subsetting IF statement works on observations before they are read into the PDV.
D. The WHERE and subsetting IF statements can be used interchangeably in all SAS programs.
[정답]B
[풀이]
Program Data Vector (PDV)란, SAS가 output data를 하나하나 지어가는 메모리 공간을 의미합니다.
이 안에는 _N_, _ERROR_ 변수뿐만 아니라 모든 data의 변수들, 형식, 뒤에서 배울 drop / keep 여부 등을 모두 담고 있습니다.
_N_은 DATA Step이 몇 번 작동했는지를 의미하며, _ERROR_는 실행 중에 에러가 발생하였는지를 담아줍니다.
이 때 0은 에러가 없음을, 1은 한 번 이상의 에러(횟수가 아닌, 존재 여부)가 있음을 의미합니다.
(= Input Buffer를 통해 만든 SAS data의 공간 확보)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.