data temp;
set salary;
by dept;
run;
Variable
|
Equivalent
|
---|---|
FIRST.variable
|
1 for the first observation
in a BY group
0 for any other observation
in a BY group
|
LAST.variable
|
1 for the last observation
in a BY group
0 for any other observation
in a BY group
|
proc sort data=sasuser.usa out=work.temp; by dept; run; data finance.budget(keep=dept payroll); set work.temp; by dept; if wagecat='S' then Yearly=wagerate*12; else if wagecat='H' then Yearly=wagerate*2000; if first.dept then Payroll=0; payroll+yearly; if last.dept; run;
proc print data=finance.budget noobs; sum payroll; format payroll dollar12.2; run;
proc sort data=sasuser.usa out=work.temp2;
by manager job_type;
data finance.budget2(keep=manager job_type payroll);
set work.temp2;
by manager job_type;
if wagecat='S' then Yearly=wagerate*12;
else if wagecat='H' then Yearly=wagerate*2000;
if first.job_type then Payroll=0;
payroll+yearly;
if last.job_type;
run;
proc print data=finance.budget2 noobs; by manager; var job_type; sum payroll; where manager in ('Coxe','Delgado'); format payroll dollar12.2; run;