************************************************************************ * Program: C:\NHANES\.sas * * Proposal: Generate Proportions Using SAS Survey Procedures * ************************************************************************; LIBNAME NH "C:\NHANES\DATA"; OPTIONS NODATE NOCENTER; option ls=72; proc format; VALUE sexfmt 1 = 'Male' 2 = 'Female' ; VALUE racefmt 1 = 'NH White' 2 = 'NH Black' 3 = 'Mexican American' 4 = 'Other' ; VALUE agefmt 1 = '20-39' 2 = '40-59' 3 = '60+' ; VALUE hbpfmt 1 = 'High BP' 2 = 'No high BP' ; VALUE bpfmt 1 = 'High BP' 0 = 'No high BP' ; VALUE hbp2fmt 100 = 'High BP' 0 = 'No high BP' ; VALUE selfmt 1= 'Age ge 20' 2= 'Age lt 20'; run; data ANALYSIS_DATA; merge NH.ANALYSIS_DATA; if ridstatr = 2; ***examined ; /*variable created for study subpopulation of interest:used on domain statement for SAS Survey procedure*/ if ridageyr ge 20 then sel=1; else sel=2; age = .; if 20 LE ridageyr LE 39 then age=1; if 40 LE ridageyr LE 59 then age=2; if ridageyr GE 60 then age=3; race=.; if ridreth1=3 then race=1; if ridreth1=4 then race=2; if ridreth1=1 then race=3; if ridreth1=2 or ridreth1=5 then race=4; *** code to define mean blood pressure measures and HBP ****; n_sbp = n(of bpxsy1-bpxsy4); n_dbp = n(of bpxdi1-bpxdi4); *Setting DBP values of 0 as missing for calculating average; array _DBP bpxdi1-bpxdi4; do over _DBP; if (_DBP = 0) then _DBP = .; end; mean_sbp = mean(of bpxsy1-bpxsy4); mean_dbp = mean(of bpxdi1-bpxdi4); if BPQ050a=1 then HBP_trt=1; else if BPQ020 in (1,2) and BPQ050a < 7 then HBP_trt=0; if n_sbp>0 and n_dbp>0 then do; if mean_sbp>=140 then SBP140=1; else SBP140=0; if mean_dbp>=90 then DBP90=1; else DBP90=0; end; if HBP_trt>=0 and SBP140>=0 and DBP90>=0 then do; if HBP_trt=1 or SBP140=1 or DBP90=1 then HBP=1; else HBP=2; end; hbpx=.; if hbp =1 then hbpx =100; if hbp =2 then hbpx =0; LABEL age = 'AGE GROUP' race = 'Race Ethnicity' riagendr = 'Gender' sel = 'Subpop: 1=age ge 20 2=age lt 20' ; RUN; ods trace on; proc surveymeans data=ANALYSIS_DATA nobs mean stderr; stratum sdmvstra; cluster sdmvpsu; class riagendr age race; domain sel sel*riagendr*age*race; var hbpx; weight wtmec4yr; format sel selfmt. riagendr sexfmt. age agefmt. race racefmt. hbpx hbp2fmt.; ods output domain(match_all)=domain; /*output dataset(s)= # of request on domain statement: in this example*/ /*there are two requests 'sel'(domain) and 'sel*riagendr*age'(domain1)*/ RUN; data all; set domain domain1; if sel=1; /*Here is 1 due to format selfmt. format*/ run; proc print noobs data=all split='/'; var riagendr age race N mean stderr; format n 5.0 mean 6.2 stderr 5.3; label N='Sample'/'Size' mean='Percent' stderr='Standard'/'error'/'of the'/'percent'; title1 'Percent of Adults 20 years and older with high blood pressure, 1999-2002'; run;