Study/SAS BASE

SAS BASE Q48. select ~ when 구문

나루다루 2018. 10. 31. 22:04
728x90
반응형

QUESTION NO: 48

The following SAS program is submitted:

data work.flights;

destination = 'cph';

select(destination);

when('LHR') city = 'London';

when('CPH') city = 'Copenhagen';

otherwise city = 'Other';

end;

run;

 

What is the value of the CITY variable?

 

A. Other

B. Copenh

C. Copenhagen

D. ''(missing character value)

 

 

Answer: A





# 문제 풀이

 - select ~ when 구문은 if ~ else 구문과 비슷하다.

  - select(destination) : destination 변수를 선택. (해당 변수 내의 데이터들을 이용하기 위해)

  - when('LHR') city = 'London' : 조건문이다. destination 변수 내의 데이터가 LHR이면 city 변수에는 London을 입력한다.


 - select문에는 end가 필요하다.


 - 데이터의 대소문자를 구별한다.

  - cph와 CPH는 다르므로 otherwise쪽을 적용하여 정답은 Ohter.


 - select 구문은 if 구문으로 나타내보았다.


                                                               


                

728x90
반응형