DATA Step, Macro, Functions and more

Proc Summary Assistance

Reply
Contributor
Posts: 59

Proc Summary Assistance

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'.

Super User
Posts: 10,490

Re: Proc Summary Assistance

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.

Ask a Question
Discussion stats
  • 1 reply
  • 128 views
  • 0 likes
  • 2 in conversation