The SAS Output Delivery System and reporting techniques

Proc report totals and percentage help

Reply
Regular Contributor
Posts: 178

Proc report totals and percentage help

data test;

infile datalines;

input ctr $ cnt ;

return;

datalines;

4411 5

4455 15

4466 6

4477 11

;

run;

 

proc report = test style(summary)=Header;

title 'test';

column ctr cnt PctTot;

define ctr /order order=data style (column)=Header;

define cnt /sum f=comma6.;

define PctTot ?????????????

compute after ctr ;

line ' ';

endcomp;

run;

 

I am attempting to do the following:

 

Desired Output

Title ‘ test’

Ctr                         Cnt                 PctTot

4411                      5                   13.51%     

4455                      15                 40.54%   

4466                       6                  16.21%

4477                       11                 29.72%   

Grand Total            37                100.00

 

I need to round the PctTot   2 decimal places and include lines as well as a Grand Total

PROC Star
Posts: 2,220

Re: Proc report totals and percentage help

PROC Star
Posts: 2,220

Re: Proc report totals and percentage help

Super User
Posts: 10,610

Re: Proc report totals and percentage help

How about this one.


data test;
infile datalines;
input ctr $ cnt ;
return;
datalines;
4411 5
4455 15
4466 6
4477 11
;
run;
 

proc report data= test nowd style(summary)=Header;
title 'test';
column ctr cnt PctTot;
define ctr /order order=data style (column)=Header ;
define cnt /sum f=comma6.;
define PctTot/computed f=percent8.2;
compute before;
 sum=cnt.sum;
endcomp;
compute PctTot;
 pcttot=cnt.sum/sum;
endcomp;
compute after;
 ctr='Total';
endcomp;
rbreak after /summarize;
run;
 


Ask a Question
Discussion stats
  • 3 replies
  • 106 views
  • 1 like
  • 3 in conversation