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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.