나루다루

SAS BASE Q58. first/last & if 본문

Study/SAS BASE

SAS BASE Q58. first/last & if

나루다루 2018. 11. 1. 23:34
728x90
반응형

QUESTION NO: 58

The following SAS program is submitted:

data work.total;

set work.salary(keep = department wagerate);

by department;

if first.department then payroll = 0;

payroll + wagerate;

if last.department;

run;

 

The SAS data set named WORK.SALARY contains 10 observations for each department, and is currently ordered by DEPARTMENT. Which statement is true?

 

A. The BY statement in the DATA step causes a syntax error.

B. The statement payroll +wagerate; in the DATA step causes a syntax error.

C. The values of the variable PAYROLL represent the total for each department in the WORK.SALARY data set.

D. The values of the variable PAYROLL represent a total for all values of WAGERATE in the WORK.SALARY data set.

 

 

Answer: C





# 문제 풀이

 - first, last : 정렬이 돼야 사용 가능. data step 내에서만 존재 -> 출력 x

  - first.department : department 내의 여러 범주의 변수들 중 범주의 각 첫번째 변수에 1을 할당하고, 나머지 변수에는 0을 할당.


 - if 변수 <=> if 변수=1 : 변수=1을 만족하는 레코드 선택



 - 노란색 부분만 출력된다. first와 last는 출력 x

 - 범주의 마지막 payroll은 해당 범주의 총합을 나타낸다. 




728x90
반응형

'Study > SAS BASE' 카테고리의 다른 글

SAS BASE Q60. @@ (???)  (0) 2018.11.01
SAS BASE Q59. @ & informat [수정] ???  (0) 2018.11.01
SAS BASE Q57.  (0) 2018.10.31
SAS BASE Q56. le & ge  (0) 2018.10.31
SAS BASE Q55. weekdate  (0) 2018.10.31
Comments