The following data choices are listed in the workclass field in the table loss_payments: "Retention" "Liquidation"
Here is an example:
proc summary data=loss_payments sum nway;
where work_class = 'Retention';
class iv_grp work_status;
var age_grp:;
output out=retention(drop=_type_ rename=(_freq_=total)) sum=;
run;
data retention_pct;
set retention;
array age_grp[5];
array pct[5];
do i=1 to 5;
if total then pct = round(age_grp/total,.0001);
end;
run;
proc sort data=retention_pct;
by iv_grp descending workout_status;
run;
I need to take two records that appear in the results, Prep1 and Prep2 and create a dummy work_class called "Prep". I then need to do a proc summary on those records that are Prep1 or Prep2 following the logic above. So work_class = 'Retention' is replaced by work_class = 'Prep'.
How many total values are there for work_class? If they are only Retention, Prep1 and Prep2 you can simplify the process with a custom format and not use where statements.
This format allows combining the two groups into one and ignores other values of work_class
proc format library=work;
value $work_class
"Prep1", "Prep2"="Prep"
;
run;
proc summary data=loss_payments sum nway;
class work_class iv_grp work_status;
var age_grp:;
output out=retention(drop=_type_ rename=(_freq_=total)) sum=;
format work_class $work_class.;
run;
Then the percent calculation is the same and you pick where you want work_class in the final sort order.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.