DM Stat-1 Articles
Link to Home

Link to Articles

Link to Consulting

Link to Seminar

Link to Stat-Chat

Link to Software

Link to Clients

Sample Balancing for
Database Response Models
Bruce Ratner, Ph.D. 

data sample_data;
input RESPONSE;
cards;
1
1
1
0
0
0
0
0
0
0
;
run;

title1' convenience sample ';
proc print data=sample_data;
run
;

title1' convenience sample RESPONSE rate ';
proc means data=sample_data n mean;var RESPONSE;
run
;

data sample_data;
set sample_data;

pop_RespRate=.000513;

pop_NRespRate=1-pop_RespRate;
_r=compress(put(pop_RespRate,8.7),'.');
_n=compress(put(pop_NRespRate,8.7),'.');
pop_RR=input(_r,10.);
pop_NR=input(_n,10.);
m=1;
cnt_RR=0;cnt_NR=0;
if RESPONSE=1 then cnt_RR=1;
if RESPONSE=0 then cnt_NR=1;
run;

proc means data=sample_data noprint;
var cnt_RR cnt_NR;
output out=sam_CNTS (drop=_TYPE_ _FREQ_)sum=sam_RR sam_NR;
data sam_CNTSm;set sam_CNTS;
m=1;
run;

data sample_data;
merge sample_data sam_CNTSm;by m;
WT=1;
if RESPONSE=0
then WT=int( (sam_RR/sam_NR)/(pop_RR/pop_NR) );
run;

title1' convenience sample with weighting variable WT ';
proc print data=sample_data;var RESPONSE WT;
run
;

title1' balanced sample RESPONSE rate ';
proc means data=sample_data n mean;var RESPONSE;
freq WT;
run;



For more information about this article, call Bruce Ratner at 516.791.3544,
1 800 DM STAT-1, or e-mail at br@dmstat1.com.