SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 22


The following SAS program is submitted:

data work.totalsales (keep = monthsales{12});
set work.monthlysales (keep = year product sales); 

array monthsales{12);
do i = 1 to 12; monthsales{i) = sales;
end;
run;

The program fails execution due to syntax errors. What is the cause of the syntax error?


A. The variable MONTHSALES does not exist.
B. An array cannot be referenced on a KEEP data set option.
C. The KEEP= data set option should be (KEEP = MONTHSALES).
D. The KEEP= data set option should be the statement KEEP MONTHSALES{12}.





문법 에러의 원인을 찾는 문제인데요. 

array는 keep option과 같이 나올 수 없는 문법이라서 B. 



Answer: B 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 21


The following SAS program is submitted: data work.sales;
do year = 1 to 5;
do month = 1 to 12;

x+ 1;
end;
end;
run;



How many observations are written to the WORK.SALES data set?


A. 0 

B. 1 

C. 5 

D. 60



12번 문제 참고하세요. 링크링크>> http://statnmath.tistory.com/171  


여기서 따로 output으로 보내는 설정이 없어서 계속 반복문이 덮어쓰게 됩니다. 

따라서 최종적으로 PDV에서는 


year     month    X

5           12       60 

이렇게 되면서 observation은 결국 1개가 됩니다. 





덮어쓰는걸 원치 않을땐 아래처럼 output; 을 넣어줘야 합니다. - 이게 12번 문제예요.


do year = 1 to 5;
do month = 1 to 12;

x+ 1;

output; 
end;
end;


Answer: B 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 20


Given the SAS data set PRICES: 


PRICES Prodid price producttype sales returns 

K125 5.10 NETWORK 15 2 

B132S 2.34 HARDWARE 300 10 

R18KY2 1.29 SOFTWARE 25 5 

3KL8BY 6.37 HARDWARE 125 15 

DY65DW 5.60 HARDWARE 45 5 

DGTY23 4.55 HARDWARE 67 2 


The following SAS program is submitted: 


data hware inter cheap; 

set prices(keep = productype price); 

if producttype = 'HARDWARE' then output hware; 

else if producttype = 'NETWORK' then output inter; 


if price le 5.00;  <- PDV에만 적용됩니다

run; 


How many observations does the HWARE data set contain?


A. 0

B. 2 

C. 3 

D. 4



PDV(Program Data Vector)는 데이타가 정리되는 과정이고요. 이 과정이 마치면 OUTPUT DATA로 물리적으로 완성된 데이타라고 생각하면 됩니다. 



hware inter cheap 데이터를 만들려고 하는데요. 이때 productype price 변수만 가져오려고 합니다. 참고로 set으로 데이타를 불러오게되면, obervation이 line by line으로 불러오게 됩니다. 예를들어 set으로 price를 가져올때 6개의 observations이 하나씩 불러오게 된다는 뜻이예요.  


첫번째 observation: K125 5.10 NETWORK 15 2  

여기서 price 의 값 5.10을 불러옵니다. 그러면 PDV에서 세개의 데이타셋 안에 producttype과 price 값이 들어가게 됩니다. 


if producttype = 'HARDWARE' then output hware; 에서, 첫번째 observation의 productype는 NETWORK이니까 이 문구는 무시하고요. 


if producttype = 'NETWORK' then output inter; 이 문구가 해당되니까 inter라는 데이타셋에만 PDV상태에서 output상태로 내보내게 됩니다. 


if price le 5.00; 에서는 해당되지 않으니까 PDV에서 값이 사라지게 됩니다. (이건 취소선으로 표시한거예요) 


PDV                                   OUTPUT

hware                               hware 

productype price               productype price

NETWORK 5.10


inter                                  inter             

productype price               productype price

NETWORK 5.10               NETWORK 5.10


cheap                               cheap 

productype price               productype price

NETWORK 5.10



두번째 Observation: B132S 2.34 HARDWARE 300 10

아까 첫번째에서 값이 5.10이니까 PDV에서는 파일이 사라졌고요. 

두번째 observation으로 왔습니다. 


if producttype = 'HARDWARE' then output hware; 에서, 두번째 observation의 productype는 Hardware이니까 PDV에 다 들어가고, hware 아웃풋으로도 보내지게 되네요.  


if producttype = 'NETWORK' then output inter; 이 문구는 해당되지 않죠. 


if price le 5.00; 에서 해당되니까 PDV에서는 그대로 있는 상태가 됩니다. 



PDV                                   OUTPUT 

hware                               hware 

productype price               productype price

Hardware 2.34                  Hardware 2.34


inter                                  inter             

productype price               productype price

Hardware 2.34                  NETWORK 5.10


cheap                               cheap 

productype price               productype price

Hardware 2.34




세번째 Observation: R18KY2 1.29 SOFTWARE 25 5 

if producttype = 'HARDWARE' then output hware; 해당사항 없습니다. 

if producttype = 'NETWORK' then output inter; 해당사항 없습니다. 

if price le 5.00; 해당사항 없습니다.


PDV                                   OUTPUT 

hware                               hware 

productype price               productype price

Hardware 2.34                  Hardware 2.34

            


inter                                  inter             

productype price               productype price

Hardware 2.34                  NETWORK 5.10


cheap                               cheap 

productype price               productype price

Hardware 2.34

 

 

이렇게 observation 6까지 진행하게되면~ 이런 결과가 됩니다. 


PDV                                   OUTPUT 

hware                               hware 

productype price               productype price

Hardware 2.34                  Hardware 2.34

Hardware 4.55                  Hardware 6.37

       Hardware 5.6

       Hardware 4.55



inter                                  inter             

productype price               productype price

Hardware 2.34                  NETWORK 5.10

Hardware 4.55


cheap                               cheap 

productype price               productype price

Hardware 2.34

Hardware 4.55



Answer: D 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 19

The following SAS program is submitted:

data work.passengers; 

if OrigPassengers = then OrigPassengers= 100;  

TransPassengers= 100;
OrigPassengers= .;
TotalPassengers= sum (OrigPassengers, TransPassengers) +0; 

run;


What is the value of the TOTALPASSENGERS variable in the output data set?


A. 0
B. 100
C. 200
D. (missing numeric value)



if OrigPassengers = then OrigPassengers= 100;  <- OrigPassgengers이 missing value 이면 이 값을 100으로 해줍니다. 


하지만, OrigPassengers가 다시 .; 이렇게 되어서 missing value가 할당되었습니다. 


sum(a,b) 경우 - missing value를 무시하고요. (1 + . = 1) 

a+b 경우, 하나가 missing value이면 결과값도 missing value 입니다. (1+ . = .) 


그래서 

TotalPassengers= sum (OrigPassengers, TransPassengers) +0;  

는 곧, sum (OrigPassengers, TransPassengers) 

         -> sum (missing value, 100) + 0

         -> 100+0 

          = 100이 됩니다. 



Answer: B 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 18


The SAS data set PETS is sorted by the variables TYPE and BREED. 

The following SAS program is submitted:


proc print data = pets;
vartype breed;

sum number;

run;


What is the result?


A. The SUM statement produces only a grand total of NUMBER.
B. The SUM statement produces only subtotals of NUMBER for each value of TYPE.
C. The SUM statement produces both a grand total of NUMBER and subtotals of NUMBER for each 
value of TYPE.

D. Nothing is produced by the SUM statement; the program fails to execute.



PETS이라는 데이타가 있는데요. TYPE과 BREED의 변수가 있다고 합니다. 

var는 특정 데이타 셋 안에서 그 특정 변수만 보겠다는 뜻이고요. 

sum은 총합을 계산해주는 함수입니다. 그래서 sum이 들어가면 grand total, 총합만 나오게 됩니다. 


Answer: A 


반응형

'SAS > Base Programmer' 카테고리의 다른 글

[A00-211, Crambible] SAS Q20 - PDV / output  (1) 2017.05.24
[A00-211, Crambible] SAS Q19 - sum (a+b)  (0) 2017.05.24
[A00-211, Crambible] SAS Q17  (0) 2017.05.24
[A00-211, Crambible] SAS Q16  (0) 2017.05.24
[A00-211, Crambible] SAS Q15  (0) 2017.05.23

+ Recent posts