Solved
Contributor
Posts: 27

# proc report column percentage

A quick question, I have generated the following table using the proc report:

 Age Age Good Bad Declined Bad Rate GB Odds Proportion 18 - 22 24 4 2768 0.14 6.00 2796 23 - 24 177 58 2874 0.25 3.05 3109 25 - 26 398 83 2949 0.17 4.80 3430 27 - 30 845 120 5443 0.12 7.04 6408 31 - 40 1224 255 8689 0.17 4.80 10168 41 - 48 594 99 4225 0.14 6.00 4918 49 - 54 302 52 1960 0.15 5.81 2314 55 - 65 256 33 1474 0.11 7.76 1763 66 - 72 39 6 234 0.13 6.50 279 73+ 11 4 97 0.27 2.75 112 3870 714 30713 0.16 5.42 35297

Now, how would you create another column that has the corresponding percentage of "poportion column"?

eg      2796/35297*100

3109/35297*100

3430/35297*100

.

.

.

35297/35297*100

Thanks

Accepted Solutions
Solution
‎08-23-2011 11:00 PM
SAS Super FREQ
Posts: 9,371

## proc report column percentage

Hi,

Look at the example posted here for the compute block

Where the value of region is being set to 'Total'

You should be able to run the code to see the compute block results.

Cynthia

All Replies
PROC Star
Posts: 8,165

## proc report column percentage

It would definitely help if you provided the data and code that led to the report you presented.

Contributor
Posts: 27

## Re: proc report column percentage

My apologies

data

18 - 22     4     24    2768        2796

23 - 24     58    177   2874        3109

25 - 26     83    398   2949        3430

27 - 30     120   845   5443        6408

31 - 40     255   1224  8689        10168

41 - 48     99    594   4225        4918

49 - 54     52    302   1960        2314

55 - 65     33    256   1474        1763

66 - 72     6     39    234         279

73+         4     11    97          112

code

proc report data=data nowd;

column ('Age' r_age good bad Reject BR GB total);

define r_age / order 'Age';

define good / analysis 'Good';

define Reject / analysis 'Declined';

define BR / computed 'Bad Rate' format=6.2;

define GB / computed 'GB Odds' format=6.2;

define total / analysis 'Proportion ';

compute BR;

endcomp;

compute GB;

endcomp;

compute total_pct;

total_pct =total.sum/total_sum;

endcomp;

rbreak after/ summarize dol dul;

run;

Oh, and another thing, is there any way to put the chracters "total" in the bottom left corner in the report table?? I have trying to do this for a while

Many thanks

Solution
‎08-23-2011 11:00 PM
SAS Super FREQ
Posts: 9,371

## proc report column percentage

Hi,

Look at the example posted here for the compute block

Where the value of region is being set to 'Total'

You should be able to run the code to see the compute block results.

Cynthia

Super User
Posts: 10,787

## Re: proc report column percentage

```data data;
input r_age \$10.      Bad   Good  Reject      total ;
cards;
18 - 22     4     24    2768        2796
23 - 24     58    177   2874        3109
25 - 26     83    398   2949        3430
27 - 30     120   845   5443        6408
31 - 40     255   1224  8689        10168
41 - 48     99    594   4225        4918
49 - 54     52    302   1960        2314
55 - 65     33    256   1474        1763
66 - 72     6     39    234         279
73+         4     11    97          112
;
run;
proc report data=data nowd ;
column ('Age' r_age good bad Reject BR GB total per);
define r_age / order 'Age';
define good / analysis 'Good';
define Reject / analysis 'Declined';
define BR / computed 'Bad Rate' format=6.2;
define GB / computed 'GB Odds' format=6.2;
define total / analysis 'Proportion ';
define per/computed 'percentage of poportion column' format=percent8.2;
compute BR;
endcomp;
compute GB;
endcomp;

compute before;
a=total.sum;
endcomp;
compute per;
per=total.sum/a;
endcomp;
compute after;
r_age='Total:';
endcomp;

rbreak after/ summarize dol dul;
run;
```

Ksharp

SAS Employee
Posts: 105

## proc report column percentage

Hi,

You can this:

data data;
input r_age \$  Bad   Good  Reject      total;
cards;
18-22     4     24    2768        2796
23-24     58    177   2874        3109
25-26     83    398   2949        3430
27-30     120   845   5443        6408
31-40     255   1224  8689        10168
41-48     99    594   4225        4918
49-54     52    302   1960        2314
55-65     33    256   1474        1763
66-72     6     39    234         279
73+       4     11    97          112
;
run;

proc report data=data nowd ;
column ('Age' r_age good bad Reject BR GB total total=total_pct);
define r_age / order 'Age';
define good / analysis 'Good';
define Reject / analysis 'Declined';
define BR / computed 'Bad Rate' format=6.2;
define GB / computed 'GB Odds' format=6.2;
define total / analysis 'Proportion ';
define total_pct / pctsum format=percent6.2 'total_pct  ';
compute BR;
endcomp;
compute GB;
endcomp;
rbreak after/ summarize dol dul;
compute after;
r_age = 'Total';
endcomp;

run;

🔒 This topic is solved and locked.