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 WORK.SALARY, currently ordered by DEPARTMENT, contains 100 observations for each of 5 departments.
Which one of the following represents how many observations the WORK.TOTAL data set contains?
A. 5
B. 20
C. 100
D. 500
Click Comment link to get answer
A
ReplyDeleteA
ReplyDeletecan anyone explain how?
ReplyDeleteThe most important statement in the program for this question is if last.department;
ReplyDeleteWe will get output only if last.department becomes true and we know there are five departments and data is sorted by department so last.department will become true 5 times and thus 5 observation in output.
why 5 times
Deletewhy 5 times
DeleteThe data is sorted by department, thus we can think there are five subgroup in the dataset: dep1-dep5. Within each group, sas computes the payroll+wagerate value, and sas outputs observations when it reaches the last observation in each subgroup. Thus there will be five observations.
DeleteYou're right SAScert
ReplyDeleteIf you want to implement your payroll system check this Payroll Philippines
ReplyDelete