SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 32

Given the raw data file EMPLOYEE: 

----I----1 0---I----20---I----30
Ruth  39 11
Jose  32 22

Sue  30 33 

John  40 44


The following SAS program is submitted: 

data test;
infile'employee';
input employee_name $ 1-4;

if employee_name = 'Ruth' then input idnum 10-11; 

else input age 7-8;
run;


What value does the variable IDNUM contain when the name of the employee is "Ruth"?


A. 11
B. 22
C. 33
D. (missing numeric value)



참고로 여기서 문제는 이름과 idnum 사이에 공백이 두 칸이 있어야 한다고 하네요.


test 데이타를 만들려고 하는데요. infile을 통해 employee 데이타를 가져옵니다. 

input으로 employee_name이란 변수를 정의하는데, 이름이 문자형으로 ($), 첫번째부터 네번째까지 불러옵니다. 이렇게 input을 사용하게되면 raw 데이타를 한 행씩 불러오게 됩니다. 


employee_name (변수이름)

Ruth  (첫번째 행이 들어왔습니다) 


if employee_name = 'Ruth' then input idnum 10-11; if 구문을 만났습니다. Ruth이니까 then 이하의 구문을 확인해줘야겠죠. 그런데 또 다른 input을 만났습니다. 즉, input으로 idnum이란 변수를 만드는데 그때 10~11자리를 불러오려고 합니다. 지금 input을 두번째 만났으니 두번째 행을 읽어야겠죠. 


employee_name idnum

Ruth   22 


아직 데이타 읽는게 끝나지 않았으니 다시 input 구문으로 올라갑니다. 

input employee_name $ 1-4;

input이 세번째로 보는거니까 raw data의 세번째 행을 봅니다. 

employee_name idnum

Ruth   22 

Sue 


if employee_name = 'Ruth' then input idnum 10-11; 으로 들어오니, Sue 가 Ruth가 아니므로 그 다음줄을 봅니다. else input age 7-8; 또 input을 보네요. 지금 네번째 input을 보는거므로 raw 데이타의 네번째 행을 읽습니다. 


employee_name idnum  age 

Ruth   22 

Sue                   40


위에 최종 output입니다. 






Answer: B 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 31

Given the AIRPLANES data set 

AlRPLANES TYPE MPG

F-18 105
C-130 25
Harrier 75
A-6 110

The following SAS program is submitted: 

data gt100;

set airplanes(keep = type mpg load); 

load = mpg * 150;
run;



The program fails to execute due to syntax errors.

What is the cause of the syntax error?


A, MPG is not a numeric variable.

B. LOAD is not a variable in the data set GT100.

C. LOAD is not variable in the data set AIRPLANES.

D. LOAD must be defined prior to the SET statement.


AIRPLANES 데이터에는 TYPE와 MPG라는 변수가 있고요. 

이때, gt100이라는 데이타를 만들려고 할때, set을 이용해서 airplanes 데이터를 참고하는데, 일단 keep이란 명령어로 type, mpg을 가지고 또... load를 가져오려는데 airplanes에 load변수가 없습니다.


Answer: C 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 30


The following SAS program is submitted: 


data test;
set chemists;

itjobcode= 'Chem2'

then description = 'Senior Chemist';
else description = 'Unknown';
run;


The value for the variable JOBCODE is: JOBCODE chem2


What is the value of the variable DESCRIPTION?

A. chem2
B. Unknown
C. Senior Chemist
D. ' ' (missing character value)


chem2를 if 조건에 넣어보면 되는데요. 

itjobcode= 'Chem2' 에서 jobcode가 Chem2 인지 봐야겠죠? 아닙니다. 왜냐하면 대소문자가 맞지 않습니다. 그래서 else로 들어가서 Unknown으로 할당이 됩니다. 


Answer: B 



반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 29


The following SAS program is submitted: 

proc contents data = sashelp.class varnum

quit; 


What does the VARNUM option print?

A. a list of variable names
B. the total number of variables
C. a list of the variables in alphabetic order
D. a list of the variables in the order they were created



varnum 옵션이 들어가있으면 

조회하는 테이블에서, 테이블이 포함한 변수들이 만들어진 순서를 보여주게 됩니다.  


Answer: D 


반응형

SAS Base, A00-211 Crambible 

SAS 베이스 자격증 


QUESTION NO: 28

The contents of the raw data file PRODUCT are listed below:

--------10-------20-------30
24613 $25.31


The following SAS program is submitted:

data inventory;
infile'product';
input idnum 5. @10 price;
run;


Which one of the following is the value of the PRICE variable?

A. 25.31
B. $25.31
C. . (missing numeric value)
D. No value is stored as the program fails to execute due to errors.



inventory 데이타를 만드려고 하는데, input을 이용하여 다음처럼 idnum 변수를 만들려고 합니다. idnum 5 경우, idnum 변수가 5 자리(lengh)란 뜻이고요. 그 옆에 @하고 숫자가 나오는 형태는, 이 지점부터 변수에 대한 값을 불러오겠다는 명령어입니다. 


질문이

24613 $25.31 되어있는데요.

원래는 24613    $25.31 이렇게 중간에 공백이 4칸정도 들어간다고 합니다. 


공백 4칸이면, 10번째부터 읽으니까 $인데, 이 $는 문자입니다. 하지만 price는 숫자라서 C. missing value.이고요. 


공백이 3칸이면 10번째가 2부터 시작해서 답은 A. 


Answer: A 


반응형

+ Recent posts