SAS Base, A00-211 Crambible, SAS 크램바이블

SAS 베이스 자격증, SAS 문제풀이 



QUESTION NO: 141

The SAS data set BANKS is listed below: 


BANKS
name rate
FirstCapital 0.0718 

DirectBank 0.0721
VirtualDirect 0.0728

The following SAS program is submitted: 

data newbank;
do year = 1 to 3;
set banks;
capital + 5000;

end;
run;


Which one of the following represents how many observations and variables will exist in the SAS data set NEWBANK?


A. 0 observations and 0 variables

B. 1 observations and 4 variables 

C. 3 observations and 3 variables 

D. 9 observations and 2 variables



Bank라는 데이타안에 name과 rate이라는 변수가 있습니다. 이 데이터를 불러 이용해서 newbank 데이터를 만들려고 합니다. do 반복문을 보면, 로 year 변수가 1부터 3까지, capital 이라는 변수도 새로 생겼네요.  그래서 총 변수는 4개가 됩니다. 


이때 do 반복문에서 output이 없어서 이 결과물을 보내지 않고 계속 덮어씌우게 됩니다. 그래서 마지막 observation만 기록된 채로 do 반복문이 끝나게 되면서 결과물은 아래처럼 나오게 되어요. 


참고로 위에는 BANK데이타, 그 아래는 NEWBANK데이타 입니다.  





data sasuser.banks;

input name : $13. rate : 6.4;

cards;

FirstCapital 0.0718

DirectBank 0.0721

VirtualDirect 0.0728

;

run;

proc print;

run;


data sasuser.bank_new;

do year = 1 to 3;

set sasuser.banks;

capital + 5000;

end;

run;

proc print data=sasuser.bank_new;

run;




Answer: B 



반응형

+ Recent posts