************************************************************************ * Program: C:\NHANES\agest_prev_sudaan_poptot.sas * * Proposal: Generate population estimates in SUDAAN * ************************************************************************; libname nh 'c:\nhanes\data'; OPTIONS NODATE NOCENTER; proc format; VALUE SEXFMT 1 = 'MALE' 2 = 'FEMALE' ; VALUE RACEFMT 1 = 'NH-White' 2 = 'NH-Black' 3 = 'Mex-Am' 4 = 'Other' ; VALUE AGEFMT 1 = '20-39' 2 = '40-59' 3 = '60+' ; VALUE HBPFMT 1 = 'high BP' 2 = 'low BP' ; ; VALUE hbp2fmt 100 = 'High BP' 0 = 'No high BP' run; DATA ANALYSIS_DATA; SET NH.ANALYSIS_DATA; if ridstatr = 2; ***examined ; 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; if hbp=1 then hbpx=100; if hbp=2 then hbpx=0; LABEL age = 'AGE GROUP' race = 'Race Ethnicity' riagendr = 'Gender' ; *FORMAT age AGEFMT. SEX SFMT. race drfmt. hbp hbpfmt.; RUN; title; PROC SORT DATA=analysis_data; BY sdmvstra sdmvpsu ; RUN; PROC descript data=analysis_data design=wr noprint mean atlevel1=1 atlevel2=2 ; SUBPOPN ridageyr >=20 ; NEST sdmvstra sdmvpsu; WEIGHT wtmec4yr; SUBGROUP riagendr age race ; LEVELS 2 3 4 ; VAR hbpx; TABLE riagendr * race ; OUTPUT NSUM MEAN SEMEAN atlev2 atlev1 / FILENAME=nh9902 FILETYPE=SAS REPLACE; RUN; DATA nh9902c; SET nh9902; *calculate the nominal degrees of freedom=# of strata-# of PSUs; df=atlev2-atlev1; * calculate t-stat based on df ; tcritl=tinv(.025,df); tcritu=tinv(.975,df); *usual Wald 95% confidence interval; ll=round((mean+tcritl*semean),.01); ul=round((mean+tcritu*semean),.01); percent=round(mean,.01); sepercent=round(semean,.01); run; /* read in population totals from supplied SAS data set cpstot9902. Create age, race, gender subgroups of interest */ PROC DESCRIPT DATA=nh.cpstot9902 design=srs MEANS NOPRINT ; SUBPOPN ctutage >= 20; SUBGROUP ctutgndr ctutrace ; LEVELS 2 4 ; VAR ctutpopt; TABLES ctutgndr*ctutrace ; OUTPUT total / FILENAME=pt9902 FILETYPE=SAS REPLACE; RUN; /* sort by subdomains being reported */ proc sort data=nh9902c; by riagendr race; run; proc sort data=pt9902(rename=(ctutgndr=riagendr ctutrace=race)); by riagendr race; run; /* merge prevalence and 95% CI with population totals */ data comb; merge nh9902c(in=a) pt9902 ; by riagendr race ; if a ; /* calculate and round the population counts by applying the population totals to the % pos and the 95% CI on the % positive */ popmean=(percent/100)*total ; popl=ll/100*total ; popu=ul/100*total ; /* round and format estimates to the nearest thousand */ poplr=round(popl,1000); popur=round(popu,1000); popmeanr=round(popmean,1000); totalr=round(total,1000) ; format popmean popl popu 11.0 ; run; /* formatted printout of results */ proc print noobs split='/' double; var riagendr race percent sepercent ll ul df nsum totalr popmeanr poplr popur ; format race racefmt. riagendr sexfmt. nsum 5.0 percent 5.2 sepercent 5.2 ll 4.2 ul 4.2 df 2.0; label percent='%'/'with'/'high'/'bp' nsum='Num'/'bp'/'status' sepercent='Std'/'error' ll='Lower'/'95 %'/'Wald'/'CI' ul='Upper'/'95 %'/'Wald'/'CI' df='degrees'/'of'/'freedom' popmeanr='Pop'/'Est'/'US'/'with'/'high'/'bp' totalr='Pop'/'total'/'US' poplr='Pop Est'/'Lower'/'95 %'/'WALD'/'CI' popur='Pop Est'/'Upper'/'95 %'/'WALD'/'CI' ; ; title1 'Prevalence of persons with high Bp - US, 1999-2002'; title2 'Percent and population estimates of number with high Bp-Wald CI'; run;