BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AlexPaezSilva
Fluorite | Level 6

I had been using PROC LOGISTIC to run a logistic regression model but then it was rightly pointed out to me that 
if I am using survey weights then I should be using PROC SURVEYLOGISTIC. In the regular PROC LOGISTIC there is an option "NORM" to normalize weights in the weight statement but this does not exist in the PROC SURVEYLOGISTIC - is there another way to do this? Or does this proc do this automatically somehow?  (See below sample code). 

All I am really trying to do is to output predicted probabilities for the main outcome (SC_ETHRACE_AM) by the main Predictor (V_ASIAN) while controlling for all others (age5, sex, edu-level, etc..). But I need to normalize the weights. Any ideas? 

 

proc surveylogistic data=work.SI_v2;
CLASS V_ASIAN (ref='3') AGE5(ref='3') SEX (Ref='1') EDU_LEVEL (ref='4') REGION (ref='3') DLFS (REF='1') / param=ref;
model SC_ETHRACE_AM (event='1')=V_ASIAN age5 sex edu_level region dlfs;
weight wght_per  ;
lsmeans SC_ETHRACE_AM / ilink cl; run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
SAS_Rob
SAS Employee

Here is a simple example of how to normalize the weights so that they sum to the sample size--you would then use the new weights in the WEIGHT statement in SURVEYLOGISTIC

 

/*Create a Sample Dataset to work with*/
data test;
seed=2534565;
do i=1 to 1000;
weight=i/7;
x1=ranuni(seed);
logit=-2 + 2*x1;
p=exp(-logit)/(1+exp(-logit));
if ranuni(seed)>p then y=1; else y=0;
output;
end;
run;


/*Calculate the sum of the weights*/
proc means data=test noprint sum;
var weight;
output out=weight_sum sum=sum_wt;
run;

/*Calculate the normalized weight for each observation*/
data normalize;set test;
if _n_=1 then set weight_sum;
normwt=_FREQ_*(weight/sum_wt);
run;

proc surveylogistic data=normalize;
weight normwt;
title 'SURVEYLOGISTIC with the normalized weights that were created';
model y=x1;
run;

 

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

If you want it to do the exact same thing as in PROC LOGISTIC, you could normalize the weights yourself in a DATA step before your run PROC SURVEYLOGISTIC.

--
Paige Miller
SAS_Rob
SAS Employee

Here is a simple example of how to normalize the weights so that they sum to the sample size--you would then use the new weights in the WEIGHT statement in SURVEYLOGISTIC

 

/*Create a Sample Dataset to work with*/
data test;
seed=2534565;
do i=1 to 1000;
weight=i/7;
x1=ranuni(seed);
logit=-2 + 2*x1;
p=exp(-logit)/(1+exp(-logit));
if ranuni(seed)>p then y=1; else y=0;
output;
end;
run;


/*Calculate the sum of the weights*/
proc means data=test noprint sum;
var weight;
output out=weight_sum sum=sum_wt;
run;

/*Calculate the normalized weight for each observation*/
data normalize;set test;
if _n_=1 then set weight_sum;
normwt=_FREQ_*(weight/sum_wt);
run;

proc surveylogistic data=normalize;
weight normwt;
title 'SURVEYLOGISTIC with the normalized weights that were created';
model y=x1;
run;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 697 views
  • 0 likes
  • 3 in conversation