PROC TABULATE
6. May 2007 13:57The data used for this paper was simulated with random variable functions. It represents results of a mailed Balance Transfer offer to existing customers of a consumer credit card. Code that generated the data is shown here:proc format;
value offer low -0.45 ='A' /* hypothetical BALANCE TRANSFER Offers */
0.45<-high = 'B' ;
value $grroff 'A' = 'aoff' 'B' = 'boff'
;
value aoff low-0.10 = '1' other = '0' /* Response rates per offer */
;
value $mline 'A' = '6500' 'B' = '5400' /* Average Balance Transfer */
;
data test;
do campaign = '2004/3', '2004/4'; /* campaign quarters */
do i = 1 to 10000;
mailed=1;
offer=put(ranuni(12),offer.);
fmtuse=put(offer,$grroff.);
respond=input(putn(ranuni(14),fmtuse),best12.);
if respond then baltran=rannor(15)*500+input(put(offer,$mline.),best12.);
else baltran=.;
output;
end;
end;
run;
For the response rate, we can use the MEAN statistic since the respond variable is binary. For balance transfer per responder we can use the MEAN function as well since the non-responders received a missing value for baltran variable. Note that we format the response rate with a percentw.d format and use a dollarw.d format for the balance transfer amount.To calculate the average balance transfer for all accounts mailed is a bit tricky. We can use the PCTSUM statistic which takes the variable and divides by a denominator variable defined in “<>”. The result is multiplied by 100, which we do not require here but can correct for with a PICTURE format. Code and output is illustrated
proc format;
picture btm (round) low - high = "0,000,009" (prefix="$" mult=.01) ;
picture pct (round) low - < 0 = "0009.99%" (prefix="-")
0 - high = "0009.99%"; run;
ODS Listing CLOSE;
ODS html file="c:\TAB1.html";
proc tabulate data=test noseps;
class offer campaign;
var respond baltran mailed;
keylabel n=" " sum=" " mean=" " pctn=" " pctsum=" ";
table campaign*(offer all="TOTAL")
,
n="Mailed"*f=comma9.
pctn="%"*f=pct.
respond="Responders"*f=comma10.
respond="Response Rate"*mean*f=percent9.2
baltran="Balance Transfer per respond"*mean*f=dollar9.0
baltran=" Balance Transfer per mailed"*pctsum*f=btm.
/rts=19 row=float misstext=" " box="SUGI";
run;
ODS html close;
ODS Listing;
| SUGI | Mailed | % | Responders | Response Rate | Balance Transfer per respond | Balance Transfer per mailed | |
| campaign | offer | 4,523 | 45.23% | 470 | 10.39% | $6,511 | $677 |
| 2004/3 | A | ||||||
| B | 5,477 | 54.77% | |||||
| TOTAL | 10,000 | 100.00% | 470 | 10.39% | $6,511 | $306 | |
| 2004/4 | offer | 4,481 | 44.81% | 477 | 10.64% | $6,493 | $691 |
| A | |||||||
| B | 5,519 | 55.19% | |||||
| TOTAL | 10,000 | 100.00% | 477 | 10.64% | $6,493 | $310 | |

Email 
11/24/2010 3:28:04 AM
I really appreciate the effort you have given to this post. I am looking forward for your next post.
move4less