BookmarkSubscribeRSS Feed

SAS Ceritified Advanced Programmer 덤프 풀이 46-48

Started ‎06-15-2020 by
Modified ‎06-15-2020 by
Views 107

46번은 38번 문제와 동일하여 스킵합니다.

47. In which one of the following SAS programs is the SAS data set index named CHAR1 always used?

A. data three;

set one;

set two key = char1;

run;

B. data three;

set one;

if char1 in ('new york' ' los angeles');

run;

C. data three;

set one;

where char1 in ('new york' 'los angeles');

run;

D. proc sql;

create table three as

select *

from one, two

where one.char1 > two.char1;

quit;

정답 : A

해설 : SET문에 Key 옵션을 달아주면 해당 변수를 인덱스로 사용하겠다는 뜻입니다. (교재 522p 참고) 

 

 

 

48. The SAS data set ONE contains fifty million observations and contains the variable PRICE,

QUANTITY, FIXED and VARIABLE. Which SAS program successfully creates three new variables

TOTREV, TOTCOST and PROFIT and requires the least amount of CPU resources to be processed?

A. data two;

set one;

where totrev>1000;

totrev=sum(price*quantity);

totcost=sum(fixed, variable);

profit=sum(totrev, -totcost);

run;

B. data two;

set one;

totrev=sum(price*quantity);

where totrev>1000;

totcost=sum(fixed, variable);

profit=sum(totrev, -totcost);

run;

C. data two;

set one;

totrev=sum(price*quantity);

if totrev>1000;

totcost=sum(fixed, variable);

profit=sum(totrev, -totcost);

run;

D. data two;

set one;

totrev = sum(price*quantity);

totcost= sum(fixed, variable);

if totrev>1000;

profit=sum(totrev, -totcost);

run;

 

정답 : C

해설 : 꽤 난이도가 어려운 문제입니다. 소거법으로 풀어볼게요, A부터 보면 where 문 뒤에 totrev에 대한 변수값을 재할당하고 있네요. 이렇게 되면 Where문을 사용한 의미가 없습니다. 변수 값을 할당한 후 논리 연산자를 해야죠. B의 경우는 where를 사용하여 데이터를 조회중입니다. Subset이 클 때는 IF를 사용하시고, Subser이 작을 때는 Where를 사용하시는게 효율적입니다. 그런데 데이터 셋이 5천만 개라고 했으니 IF를 사용하는게 효율적이죠. D의 경우 totrev, totcost를 계산한 후에 if문을 걸어주네요. totrev를 계산 후 바로 IF를 적용하면, 조건에 맞는 totcast만 계산하면 됩니다. 그런데 바로 적용을 안해주니 불필요한(조건에 맞지 않는) totcost가 계산되니 비효율적입니다. 가장 효율적인 (cpu를 적게 사용하는) 문항은 C입니다.

Version history
Last update:
‎06-15-2020 04:22 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Article Labels
Article Tags