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
Hi,
Look at the example posted here for the compute block
http://communities.sas.com/message/17911#17911
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
It would definitely help if you provided the data and code that led to the report you presented.
My apologies
data
r_age Bad Good Reject total
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 bad / analysis 'Bad';
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;
BR=bad.sum/(good.sum+bad.sum);
endcomp;
compute GB;
GB = good.sum/bad.sum;
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
Hi,
Look at the example posted here for the compute block
http://communities.sas.com/message/17911#17911
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
How about:
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 bad / analysis 'Bad'; 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; BR=bad.sum/(good.sum+bad.sum); endcomp; compute GB; GB = good.sum/bad.sum; 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
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 bad / analysis 'Bad';
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;
BR=bad.sum/(good.sum+bad.sum);
endcomp;
compute GB;
GB = good.sum/bad.sum;
endcomp;
rbreak after/ summarize dol dul;
compute after;
r_age = 'Total';
endcomp;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.