******************************************************************************* * Program: C:\NHANES\LogisticRegression_SAS.sas * * Proposal: Logistic regression analysis with multiple independent variables - * SAS Survey procedure * ******************************************************************************; *Save tutorial dataset in a folder on your C drive to read into SAS; LIBNAME NH "C:\NHANES\DATA"; *LIBNAME NH "C:\myfiles"; OPTIONS NODATE NOCENTER; options ls=72; proc format; VALUE sexfmt 1 = 'Male' 2 = 'Female' ; VALUE agefmt 1='20-39 yrs' 2='40-59 yrs' 3='60 + yrs'; VALUE bpfmt 1='hypertension' 0='no hypertension' ; VALUE chfmt 1='high cholesterol' 0='not high cholesterol' ; VALUE bmifmt 1='BMI<25' 2='25<=BMI<30' 3='BMI>=30' ; run; data analysis_data; set NH.analysis_data; *create weight variable - recode WTSAF4YR as a near zero value for observations that are outside the subpopulation of interest; if ridageyr >= 20 then newweight = WTSAF4YR; else newweight = 1e-6; *create an indicator of hypertension based on blood pressure and medication; if (bpxsar >= 140 or bpxdar >= 90 or bpq050a = 1) then Hyper = 1; else if (bpxsar ne . and bpxdar ne .) then Hyper = 0; *create an indicator of high cholesterol based on total cholesterol and medication; if (lbxtc>=240 or bpq100d = 1) then HiChol = 1; else if (lbxtc ne . ) then HiChol = 0; *create bmi groups; if 0<=bmxbmi<25 then bmigrp=1; else if 25<=bmxbmi<30 then bmigrp=2; else if bmxbmi>=30 then bmigrp=3; *create age groups; if 20<=ridageyr<40 then age=1; else if 40<=ridageyr<60 then age=2; else if ridageyr>=60 then age=3; *create log of fasting triglycerides; logtrig=log(lbxtr); label hyper='Indicates if have hypertension' HiChol='Indicates if have High Cholesterol' BMIGRP='BMI groups, lean, overweight, obese' Riagendr = 'Gender' Age = 'Age Group'; run; PROC SURVEYLOGISTIC DATA = Analysis_Data; STRATUM sdmvstra; CLUSTER sdmvpsu; WEIGHT newweight; CLASS age (PARAM=REF REF='40-59 yrs') riagendr (PARAM=REF REF='Female') hichol (PARAM=REF REF='high cholesterol') bmigrp (PARAM=REF REF='25<=BMI<30'); MODEL hyper (desc)=age riagendr hichol bmigrp logtrig; title "Multiple Logistic Regression: Odds of Hypertension"; format age agefmt. riagendr sexfmt. hichol chfmt. bmigrp bmifmt.; run;