PROC TABULATE

by Irina 6. May 2007 13:57
by Jonas V. Bilenas, JP Morgan Chase, Wilmington, DE :

The 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;

 

SUGIMailed%RespondersResponse RateBalance Transfer per respondBalance Transfer per mailed
campaignoffer4,52345.23%47010.39% $6,511$677
2004/3A
B5,47754.77%    
TOTAL10,000100.00%47010.39% $6,511$306
2004/4offer4,48144.81%47710.64% $6,493$691
A
B5,51955.19%    
TOTAL10,000100.00%47710.64% $6,493$310

Tags: tabulate

SAS

Related posts

Add comment


(will show your Gravatar icon)  





Live preview

9/7/2010 11:34:25 AM

 

About the author

Irina Spivak Irina Spivak
Team Leader at G-Stat. More...


Send mail Email

Authors

Blogroll

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in

    eXTReMe Tracker