Help using Base SAS procedures

percentages in tabulate

Reply
Occasional Contributor
Posts: 11

percentages in tabulate

i have a tabulate with below output. i want the numbers to be represented as a percentage of "All". is there an easier way to do this apart from a proc summary and merge?
| Broken | Kept | |
| |------------------------------------+-----------------------------------| |
| | No_Pmt | Part_Pmt | Full_Pmt | Over_Pmt | All |
| |-----------------+----------------+----------------+-----------------+------------|
| | N | N | N | N | N |
|-----------------------------+----------------+---------------+----------------+-----------------+-------------|
|Agent | | | | | |
|-----------------------------| | | | | |
|1401 | 1.00| .| .| .| 1.00|
|-----------------------------+----------------+---------------+----------------+-----------------+-------------|
|1423 | 2.00| .| .| .| 2.00|
----------------------------------------------------------------------------------------------------------------------
Valued Guide
Posts: 2,168

Re: percentages in tabulate

probably.
what code do you have so far?
it only needs a small variation, I expect
Valued Guide
Posts: 2,168

Re: percentages in tabulate

ok here is a small attempt to demo.
Not knowing what is really wanted, and how the underlying data are structured, it probably does not hit the mark, but might give an idea
data peterC ;
input agent $ type $ amount ;
list;cards;
1401 npmt .
1401 part 123
1401 over 256
1423 npmt .
1423 npmt .
1423 full 999
1423 part 100
1423 part 115
;
proc tabulate missing formchar='|----|+|---';
class agent type ;
var amount ;
title 'payment type distribution' ;
table agent all, type=' '*pctN='%' *f= 6.1 all*N*f= 5./rts=11 box=' per-cent by number';
table agent all, type=' '*amount=' ' *pctsum='%' *f= 6.1 all*amount*sum=' '*f= 8./rts=11 box=' per-cent by value';
run;[pre]payment type distribution 16:20 Monday, January 10, 2011 1

---------------------------------------------
| | full | npmt | over | part | All |
|per-cent |------+------+------+------+-----|
|by number| % | % | % | % | N |
|---------+------+------+------+------+-----|
|agent | | | | | |
|---------| | | | | |
|1401 | .| 33.3| 33.3| 33.3| 3|
|---------+------+------+------+------+-----|
|1423 | 20.0| 40.0| .| 40.0| 5|
|---------+------+------+------+------+-----|
|All | 12.5| 37.5| 12.5| 37.5| 8|
---------------------------------------------


payment type distribution 16:20 Monday, January 10, 2011 2

------------------------------------------------
| | full | npmt | over | part | All |
|per-cent |------+------+------+------+--------|
|by value | % | % | % | % | amount |
|---------+------+------+------+------+--------|
|agent | | | | | |
|---------| | | | | |
|1401 | .| .| 67.5| 32.5| 379|
|---------+------+------+------+------+--------|
|1423 | 82.3| .| .| 17.7| 1214|
|---------+------+------+------+------+--------|
|All | 62.7| .| 16.1| 21.2| 1593|
------------------------------------------------
[/pre] and recommend the [ pre ] signals to present results in a fixed pitch for ordinary listing of tables or columns. The best place to find this is at http://support.sas.com/forums/thread.jspa?messageID=27609毙

peterC
SAS Super FREQ
Posts: 8,681

Re: percentages in tabulate

Hi:
PROC TABULATE has more percent statistics than any other procedure, starting with PCTN (percent of the overall count (or N), ROWPCTN, COLPCTN, PAGEPCTN and REPPCTN. If you want the percent of a numeric variable (not just the count), then the "SUM" version of the percent statistics: PCTSUM, ROWPCTSUM, COLPCTSUM, PAGEPCTSUM and REPPCTSUM get called into action.

As Peter said -- it is probably a simple change to the code you already have.

cynthia
Occasional Contributor
Posts: 11

Re: percentages in tabulate

thanx for the feedback. i will try and apply the suggested code.
FYI my code is as follows (with count only):

proc tabulate data= vaf_ptps_pmts3 out= vaf_ptps_pmts4;
class adj result pmt_status;
var ptp_cnt;

table adj ={label='Agent' s=[background=very dark blue foreground=white]},
result ={label=' ' s=[background=very dark blue foreground=white]}*
pmt_status ={label=' ' s=[background=very dark blue foreground=white]}
all;
where month = 'Dec-10';
run;
Valued Guide
Posts: 2,168

Re: percentages in tabulate

so that suggests a table statement like
table adj ={label='Agent' s=[background=very dark blue foreground=white]},
result ={label=' ' s=[background=very dark blue foreground=white]}*
pmt_status ={label=' ' s=[background=very dark blue foreground=white]} * pctn='%'
all *N ;

or RowPctN instead of result*pmt_status as denominator definition (since SAS91 has made that so much simpler when the table structure permits) since I cannot test on your data structure, I decided to offer the simpler alternative denominator definition ROWpctN
Message was edited by: Peter.C
Ask a Question
Discussion stats
  • 5 replies
  • 266 views
  • 0 likes
  • 3 in conversation