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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.