Hello, I am trying to calculate inverse probability weights for loss-to-followup in my cohort study. From what I've read, my stabilized weights should have a mean of 1 and the sum of the unstabilized weights should be double the sum of the stabilized weights, however, the average of my stabilized weights is 1.4. I tried two methods below (with the tables ipw22 and ipw44) I am not sure where the error in my code could be, it would be greatly appreciated if someone could help! (I had some missing data with the covariates, so I imputed with the mean or mode) so as not to lose too many subjects in the logistic regression. **I am not sure which version of SAS I am on because I use SAS through EMACS, but I think it is 9.3** /*Part1: Estimate conditional probabilities for denominator using pooled logistic regression*/ proc logistic data=tables.ipw; class <covariates>; model dropout= <covariates>/lackfit; output out=d_data (keep=n_ident d) p=d; run; /*Part2: Calculate cumulative probabilities for stabilized weights (sw)*/ proc sort data=tables.ipw; by n_ident; run; proc sort data=n_data; by n_ident; run; proc sort data=d_data; by n_ident; run; data ipw22; merge tables.ipwsimple n_data d_data; by n_ident; if dropout=1 then do; uw=1/d; /*unstabilized weight*/ sw=n/d; /*stabilized weight*/ end; else if dropout=0 then do; uw=1/(1-d); /*unstabilized weight*/ sw=(1-n)/(1-d); /*stabilized weight*/ end; run; data ipw44; merge tables.ipw n_data d_data; by n_ident; if dropout=1 then do; uw=1/d; /*unstabilized weight*/ sw=(1195/2002)/d; /*(eligible population/total population) stabilized weight*/ end; else if dropout=0 then do; uw=1/(1-d); sw=(1-(1195/2002))/(1-d); end; predict=log(d/(1-d))*log(d/(1-d)); run; /*Create term to check verifications after*/ *---------------------------------------------------- *Assess distribution of SW *Mean should be=1 *UW range should be greater than SW range *UW sum should be twice the sum of SW sum *----------------------------------------------------; proc means data=ipw22 mean sum min max; var uw sw; run; proc means data=ipw44 mean sum min max; var sw uw; run;
... View more