*****************************************************************************************************************; * Example SUDAAN code to replicate NCHS Data Brief No. 364, Figures 1 - 3 *; * Hypertension Prevalence Among Adults Aged 18 and Over: United States, 2017–2018 *; * *; * Ostchega,Y, Fryar,CD, Nwankwo, T, Nguyen, DT. Hypertension Prevalence Among Adults Aged 18 and Over: *; * United States, 2017–2018. NCHS Data Brief. No 364. Hyattsville, MD: National Center for Health Statistics. *; * 2020. *; * *; * Available at: https://www.cdc.gov/nchs/products/databriefs/db364.htm *; *****************************************************************************************************************; %global home macros titles liblabel; %let home = ./; /*Insert path to Home folder where the macro is saved*/ /*** Include Korn and Graubard macro ***/ /*** This code assumes the macro is stored in a subfolder of home called 'macros' ***/ %include "&home\macros\KG_macro.sas"; options nocenter nodate nonumber pagesize=100 linesize=150; OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; %put Run in SAS &sysver (maintenance release and release year: &sysvlong4) and SUDAAN Release 11.0.1 (SAS-Callable, 32 bit version); ** Macro To Download Data from NHANES website **; %macro CreateDS(myDS); %let i = 1; %let DS = %scan(&myDS, &i); %do %until(&DS = %nrstr()); %let Suffix = %lowcase(%substr(&DS, %eval(%length(&DS)-1))); %if (&Suffix = _j) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2017-2018/&DS..xpt"; %end; %else %if (&Suffix = _i) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2015-2016/&DS..xpt"; %end; %else %if (&Suffix = _h) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2013-2014/&DS..xpt"; %end; %else %if (&Suffix = _g) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2011-2012/&DS..xpt"; %end; %else %if (&Suffix = _f) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2009-2010/&DS..xpt"; %end; %else %if (&Suffix = _e) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2007-2008/&DS..xpt"; %end; %else %if (&Suffix = _d) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2005-2006/&DS..xpt"; %end; %else %if (&Suffix = _c) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2003-2004/&DS..xpt"; %end; %else %if (&Suffix = _b) %then %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/2001-2002/&DS..xpt"; %end; %else %do; filename &DS url "https://wwwn.cdc.gov/nchs/nhanes/1999-2000/&DS..xpt"; %end; libname &DS xport; data &DS; set &DS..&DS; run; %let i = %eval(&i+1); %let DS = %scan(&myDS, &i); %end; %mend CreateDS; ** DOWNLOAD DATASETS **; %CreateDS(demo bpq bpx); %CreateDS(demo_b bpq_b bpx_b); %CreateDS(demo_c bpq_c bpx_c); %CreateDS(demo_d bpq_d bpx_d); %CreateDS(demo_e bpq_e bpx_e); %CreateDS(demo_f bpq_f bpx_f); %CreateDS(demo_g bpq_g bpx_g); %CreateDS(demo_h bpq_h bpx_h); %CreateDS(demo_i bpq_i bpx_i); %CreateDS(demo_j bpq_j bpx_j); data demo; set demo demo_b demo_c demo_d demo_e demo_f demo_g demo_h demo_i demo_j ; run; data bpx (keep=seqn bpxsy1-bpxsy4 bpxdi1-bpxdi4); set bpx bpx_b bpx_c bpx_d bpx_e bpx_f bpx_g bpx_h bpx_i bpx_j; run; data bpq (keep=seqn bpq020 bpq050a BPQ100D); set bpq bpq_b bpq_c bpq_d bpq_e bpq_f bpq_g bpq_h bpq_i bpq_j ; run; proc sort data=demo; by seqn; run; proc sort data=bpq; by seqn; run; proc sort data=bpx; by seqn; run; data hyper_9918; merge demo bpq(keep=seqn bpq020 bpq050a BPQ100D) bpx(keep=seqn bpxsy1-bpxsy4 bpxdi1-bpxdi4); by seqn; run; Proc format; value age 1="20-39" 2="40-59" 3="60+"; value agecat 1="18-39" 2="40-59" 3="60+" 0,-2='18 and over'; value sexf 1='Men' 2='Women' 0,-2='All'; value FPL 1='<=130' 2='130-<=350' 3='>350'; VALUE EDUC 1='0.00 and indfmpir le 1.30 then FPL=1; else if indfmpir >1.30 and indfmpir le 3.50 then FPL=2; else if indfmpir >3.50 then FPL=3; *education; If ridageyr in (18,19) then do; if (dmdeduc3 >=0 and dmdeduc3 <15) or dmdeduc3=55 or dmdeduc3=66 then EDUC = 1; /*HS DIPLOMA or LESS*/ else if dmdeduc3=15 then EDUC=2; /*Some college*/ end; if dmdeduc2 in(1,2,3) then EDUC = 1; /*HS DIPLOMA or LESS*/ else if dmdeduc2=4 then EDUC=2; /*Some college*/ else if dmdeduc2=5 then EDUC =3; /*COLLEGE*/ **Hypertension prevalence; ** Count Number of Nonmissing SBP's & DBP's **; n_sbp = n(of bpxsy1-bpxsy4); n_dbp = n(of bpxdi1-bpxdi4); ** Set DBP Values Of 0 To Missing For Calculating Average **; array _DBP bpxdi1-bpxdi4; do over _DBP; if (_DBP = 0) then _DBP = .; end; ** Calculate Mean Systolic and Diastolic **; mean_sbp = mean(of bpxsy1-bpxsy4); mean_dbp = mean(of bpxdi1-bpxdi4); ** Create Hypertensive Category Variable **; ** Create Hypertensive Category Variable (code used in previous DB definitions)************************; **NOTE: These category variables can be defined as 1=100 and 0=0. In that case, means and semeans are used in SUDAAN procedure instead of percent and sepercent***; if (mean_sbp >= 130 or mean_dbp >= 80 or bpq050a = 1) then do; Hyper_new = 1; if (mean_sbp >= 130 or mean_dbp >= 80) then Controlled = 0; else if (n_sbp > 0 and n_dbp > 0) then Controlled = 1; end; else if (n_sbp > 0 and n_dbp > 0) then Hyper_new = 0; if (mean_sbp >= 140 or mean_dbp >= 90 or bpq050a = 1) then do; Hyper_old = 1; if (mean_sbp >= 140 or mean_dbp >= 90) then Controlold = 0; else if (n_sbp > 0 and n_dbp > 0) then Controlold = 1; end; else if (n_sbp > 0 and n_dbp > 0) then Hyper_old = 0; ***aware**********************************************************************; if bpq020=1 then aware=1; else if bpq020=2 then aware=0; **Subpopulation of interest ***************************************************; if ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0) then sel1=1; * indicator for overall estimates *; one=1; run; **************************************************************************; *Subsetting NHANES 2017-2018 data*; **************************************************************************; data hyper_1718; set hyper9918; if sddsrvyr=10; run; * sort by strata and PSU before running SUDAAN procedures *; proc sort data = hyper_1718; by sdmvstra sdmvpsu; run; *********************************************************; * AGE-ADJUSTED PREVALENCE RATES *; *********************************************************; title "Age-adjusted Prevalence of hypertension, by sex, age, race and Hispanic origin, and education level"; * Age-adjustment weights for adults aged 18 and over from estimated year 2000 Census population, with age groups 18-39,40-59, 60+ years; %let ageShares = 0.4203 0.3572 0.2225; proc descript data=hyper_1718 atlevel1=1 atlevel2=2 ; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria) *; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class one riagendr agecat race_et4 educ /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new ; catlevel 1 ; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; /*ALTERNATIVE*; stdwgt 0.4203 0.3572 0.2225; */ * Table(s) statement: specifies cross-tabulations for which estimates are requested. *; * request age-standardized estimates of interest *; * also request age-specific estimates (i.e. interaction with agecat) which are needed to calculate Korn and Graubard confidence intervals *; tables riagendr*agecat riagendr*race_et4*agecat riagendr*educ*agecat; print nsum percent sepercent lowpct uppct/style=nchs percentfmt=f8.1 lowpctfmt=f8.1 uppctfmt=f8.1; output nsum percent sepercent atlev1 atlev2 /filename=HTNp percentfmt=f8.1 sepercentfmt=f8.1 replace; rtitle "Tables 1,2,3 Age adjusted prevalence of hypertension (new=130/80;old=140/90),by sex,age, r/e adults 18 years and older, US, 2017-2018"; rfootnote "Age standardized by the direct method to the year 2000 census population estimates using the age groups 18-39,40-59, 60+ years"; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; rformat educ educ.; run; * Call macro to calculate Korn and Graubard confidence intervals, for age-adjusted estimates *; * see the macro documentation for more detail on options *; %calculate_KornGraubard_CIs(age_adjusted=yes, dropAgeSpecific=no); data HTNp_KG2; set HTNp_KG; * Keep age-specific estimates only for table 1 *; if (tableno in (2,3) and agecat not in (0,-2)) then delete; * delete totals for tables 2 and 3 *; if race_et4=0 or educ=0 then delete; run; proc print data=HTNp_KG2 (where=(tableno=1)) noobs label; var riagendr agecat nsum percent sepercent; title "Data table for Figure 1. Prevalence of hypertension among adults aged 18 and over, by sex and age: United States, 2017–2018"; footnote "Estimates for age group 18 and over are age adjusted by the direct method to the U.S. Census 2000 population using age groups 18–39, 40–59, and 60 and over."; run; proc print data=HTNp_KG2 (where=(tableno=2 and race_et4 in (1,2,4))) noobs label; var riagendr race_et4 nsum percent sepercent; label race_et4="Race and Hispanic origin"; title "Data table for Figure 2. Age-adjusted prevalence of hypertension among adults aged 18 and over, by sex and race and Hispanic origin: United States, 2017–2018"; footnote "All estimates are age adjusted by the direct method to the U.S. Census 2000 population using age groups 18–39, 40–59, and 60 and over."; run; proc print data=HTNp_KG2 (where=(tableno=3 )) noobs label; var riagendr educ nsum percent sepercent; title "Data table for Figure 3. Age-adjusted prevalence of hypertension among adults aged 18 and over, by sex and education: United States, 2017–2018"; footnote "All estimates are age adjusted by the direct method to the U.S. Census 2000 population using age groups 18–39, 40–59, and 60 and over."; run; title; footnote; *********************************************************************************; *T-TESTS; *tests between sexes; **********************************************************************************; title "Figure 1: Pairwise t tests for unadjusted prevalence of hypertension, by age and sex, adults 18 years and older, US, 2017-2018"; proc descript data=hyper_1718 filetype=sas nomarg; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr agecat race_et4 educ /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated for each variable in the class statement.*; table agecat; /* Contrast statement: requests specified t-tests*;*/ contrast riagendr =(-1 1 )/name="contrast Male-Female"; /* Pairwise statement: requests all contrasts*;*/ pairwise riagendr/name="pairwise sex"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; rformat educ educ.; rformat sddsrvyr s.; run; title "Figure 1: Pairwise t tests for age-adjusted prevalence of hypertension, by sex, adults 18 years and older, US, 2017-2018"; proc descript data=hyper_1718 filetype=sas nomarg; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria) *; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class riagendr agecat /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated for each variable in the class statement.*; table _one_; /* Contrast statement: requests specified t-tests*;*/ contrast riagendr =(-1 1 )/name="contrast Male-Female"; /* Pairwise statement: requests all contrasts*;*/ pairwise riagendr/name="pairwise sex"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; rformat educ educ.; rformat sddsrvyr s.; run; *********************************************************************************; *ANALYSIS OF TRENDS; **********************************************************************************; title "Figure 1: Trends by age group for unadjusted prevalence of hypertension, by sex, adults 18 years and older, US, 2017-2018"; proc descript data=hyper_1718 filetype=sas ; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr agecat race_et4 educ /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated.*; table riagendr; * Polynomial statement: requests analysis of linear and quadratic trends*; polynomial agecat=2/name="Age trends"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; rformat educ educ.; rformat sddsrvyr s.; run; *********************************************************************************; *T-TESTS; *tests between race and Hispanic origin; **********************************************************************************; title "Figure 2: Pairwise t tests for age-adjusted prevalence of hypertension, by sex, and race and Hispanic origin, adults 18 years and older, US, 2017-2018"; proc descript data=hyper_1718 filetype=sas notsorted; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr agecat race_et4 educ /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; /*ALTERNATIVE*; stdwgt 0.4203 0.3572 0.2225; */ * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated.*; table riagendr; * Contrast statement: requests specified t-tests*; contrast race_et4 = (-1 1 0 0 0)/ name="NHW v NHB"; contrast race_et4 = (-1 0 0 1 0)/ name="NHW v Hispanic"; contrast race_et4 = (0 -1 0 1 0)/ name="NHB v Hispanic"; * Pairwise statement: requests all contrasts*; pairwise race_et4/name="pairwise race"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1 ; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; run; *********************************************************************************; *T-TESTS; *tests between sexes; **********************************************************************************; title "Figure 3: Pairwise t tests for age-adjusted prevalence of hypertension, by sex and education level, adults 18 years and older, US, 2017-2018"; proc descript data=hyper_1718 filetype=sas notsorted; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr agecat race_et4 educ /nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; /*ALTERNATIVE*; stdwgt 0.4203 0.3572 0.2225; */ * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated.*; table educ; * Contrast statement: requests specified t-tests*; contrast riagendr =(-1 1 )/name="contrast Male-Female"; * Pairwise statement: requests all contrasts*; pairwise riagendr/name="pairwise sex"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1 ; rformat agecat agecat.; rformat riagendr sexf.; rformat educ educ.; run; *****************************************************************************; *FIGURE 4**; *****************************************************************************; Title "Figure 4: Age-adjusted trend in hypertension prevalence among adults aged 18 and over, by sex: United States, 1999–2018"; %let ageShares = 0.4203 0.3572 0.2225; proc descript data=hyper9918 notsorted atlevel1=1 atlevel2=2 nomarg; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr agecat race_et4/nofreq; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated.*; tables sddsrvyr riagendr*sddsrvyr; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; /*ALTERNATIVE*; stdwgt 0.4203 0.3572 0.2225;*/ print nsum percent sepercent /style=nchs percentfmt=f8.1 sepercentfmt=f8.1 ; output nsum percent sepercent atlev1 atlev2 /filename=HTNp replace; rtitle "Age-adjusted trend in hypertension prevalence among adults aged 18 and over, by sex: United States, 1999–2018"; rformat agecat agecat.; rformat riagendr sexf.; rformat race_et4 race4fmt.; rformat hyper_new hyper_new.; rformat sddsrvyr s.; run; *********************************************************************************; *Analysis of trends; **********************************************************************************; Title " Trend test for age-adjusted prevalence of hypertension, adults 18 years and older, US, 1999-2016"; proc descript data=hyper9918 filetype=sas nomarg notsorted; * Nest statement: PSUs nested within Strata accounts for the design effects*; nest sdmvstra sdmvpsu; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; weight wtmec2yr; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria*; subpopx ridageyr >=18 and ridexprg ne 1 and (n_sbp ne 0 or n_dbp ne 0); * Class statement: specify categorical variable(s)*; class sddsrvyr riagendr race_et4 agecat/nofreq ; * Var statement: specify the analysis variable(s),and the level(s) of the analysis variable(s)*; var hyper_new; catlevel 1; * Table(s) statement: specifies cross-tabulations for which estimates are requested. If a table statement is not present, a one-dimensional distribution is generated.*; table _one_ riagendr; * Stdvar statement: specifies the variables used to calculate the standard age proportions*; stdvar agecat; * Stdwgt statement: specifies the precalculated standard age proportions*; stdwgt &ageShares; /*ALTERNATIVE*; stdwgt 0.4203 0.3572 0.2225;*/ * Poly statement: requests analysis of linear and quadratic trends*; poly sddsrvyr=2 / name="HTN trend"; print nsum="samsize" percent sepercent T_PCT P_PCT /style=nchs percentfmt=f8.1 ; rformat agecat agecat.; rformat riagendr sexf.; rformat hyper_new hyper_new.; run;