*****************************************************************************************************************; * Example SUDAAN code to replicate NCHS Data Brief No. 369, Figures 1 - 5 *; * Prevalence of Prescription Pain Medication Use Among Adults: United States, 2015–2018 *; * *; * Hales CM, Martin CB, Gu Q. Prevalence of Prescription Pain Medication Use Among Adults: United States, *; * 2015–2018. NCHS Data Brief. No 369. Hyattsville, MD: National Center for Health Statistics. 2020. *; * *; * *; * Available at: https://www.cdc.gov/nchs/products/databriefs/db369.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 xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2017-2018/&DS..xpt"; %end; %else %if (&Suffix = _i) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2015-2016/&DS..xpt"; %end; %else %if (&Suffix = _h) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2013-2014/&DS..xpt"; %end; %else %if (&Suffix = _g) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2011-2012/&DS..xpt"; %end; %else %if (&Suffix = _f) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2009-2010/&DS..xpt"; %end; %else %if (&Suffix = _e) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2007-2008/&DS..xpt"; %end; %else %if (&Suffix = _d) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2005-2006/&DS..xpt"; %end; %else %if (&Suffix = _c) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2003-2004/&DS..xpt"; %end; %else %if (&Suffix = _b) %then %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/2001-2002/&DS..xpt"; %end; %else %do; filename xptIn url "https://wwwn.cdc.gov/nchs/nhanes/1999-2000/&DS..xpt"; %end; libname xptIn xport; data &DS; set xptIn.&DS; run; libname xptIn clear; filename xptIn clear; %let i = %eval(&i+1); %let DS = %scan(&myDS, &i); %end; %mend CreateDS; * Download datasets *; %CreateDS(demo_f demo_g demo_h demo_i demo_j rxq_rx_f rxq_rx_g rxq_rx_h rxq_rx_i rxq_rx_j); * Append datasets over several survey cycles *; data demo_all; set demo_f demo_g demo_h demo_i demo_j; run; data rxq_rx_all; set rxq_rx_f rxq_rx_g rxq_rx_h rxq_rx_i rxq_rx_j; run; proc sort data=demo_all; by seqn; run; proc sort data=rxq_rx_all; by seqn; run; * Merge datasets *; data alldrugs; merge demo_all rxq_rx_all; by seqn; * inAnalysis if adult and answered the question about use of any prescriptions in the past 30 days (missing if refused or dont know) *; if rxduse in (7,9) then rxduse=.; inAnalysis= (ridageyr>=20 and rxduse in (1,2)); run; PROC CONTENTS DATA=alldrugs; RUN; * get prescription medication - drug information*; %createDS(rxq_drug); * merge in drug info *; proc sql noprint; create table alldrugs_dtl as ( select a.*, b.* from alldrugs a left outer join rxq_drug b on a.rxddrgid=b.rxddrgid) order by a.seqn ; quit; * add indicators for whether each drug is an opioid pain med or non-opioid pain med - defined only among adults who answered the Rx question *; data alldrugs_dtl2; set alldrugs_dtl; if inAnalysis then do; * define opioid pain medication drug - at individual drug level *; * check 3rd level category codes (up to 4 drug categories per drug) *; * 60 (narcotic analgesics) and 191 (narcotic anagesic combinations) *; isOpioid = ( RXDDCI1C in (60,191) or RXDDCI2C in (60,191) or RXDDCI3C in (60,191) or RXDDCI4C in (60,191) )*100; * exclude medications containing buprenorphine (primarily used to treat opioid addiction) *; if index(rxddrug, "BUPRENORPHINE")>0 then isOpioid=0; * define non-opioid pain medication drug *; * check 3rd level category codes (up to 4 drug categories per drug) *; * 63 (analgesic combinations), 193 (antimigraine agents), 278 (cox-2 inhibitors); * 61 (nonsteroidal anti-inflammatory agents), and 62 (salicylates) *; isNonOpioid = ( RXDDCI1C in (63,193,278,61,62) or RXDDCI2C in (63,193,278,61,62) or RXDDCI3C in (63,193,278,61,62) or RXDDCI4C in (63,193,278,61,62)) *100; * exclude aspirin as a single ingredient medication (primarily for CVD prevention) *; if rxddrgid="d00170" then isNonOpioid=0; * define total pain medication: opioid + non-opioid + analgesics-unspecified (drug ID rxddrgid="c00058") *; isPainMed=(isOpioid=100 or isNonOpioid=100 or rxddrgid="c00058")*100; end; run; * aggregate to SP level - 0/100 indicators for whether SP used any Opioid and any non-Opioid pain meds (non-exclusive indicators) *; proc means data=alldrugs_dtl2 noprint nway; var isOpioid isNonOpioid isPainMed inAnalysis; class seqn; output out=spSummary max=anyOpioid anyNonOpioid anyPainMed inAnalysis; run; * define outcomes and covariates *; data sp_level; merge demo_all (in = a) spSummary; by seqn; if inAnalysis then do; if anyOpioid=. or anyNonOpioid=. then ProblemFlag=1; * Define variable for use of 1+ non-opioid pain meds _without_ use of opioids *; NonOpioidOnly=(anyNonOpioid=100 and anyOpioid=0)*100; end; * race and Hispanic origin *; select (ridreth3); when (1,2) raceEthCat=4; when (3) raceEthCat=1; when (4) raceEthCat=2; when (6) raceEthCat=3; when (7) raceEthCat=5; otherwise; end; label raceEthCat="Race and Hispanic origin"; * age group *; if 20<=ridageyr<40 then ageCat=1; else if 40<=ridageyr<60 then ageCat=2; else if 60<=ridageyr then ageCat=3; label ageCat ="Age group"; * overall *; one=1; * survey year starting with 1=2009-2010 for trend testing *; sddsrvyr_start09=sddsrvyr-5; sddsrvyr_start09_sq=sddsrvyr_start09**2; run; proc freq data = sp_level; tables sddsrvyr*problemFlag / missing; run; proc sort data = sp_level; by sdmvstra sdmvpsu ; run; * create base dataset for most figures: 2015-2018 *; data Rx; set sp_level; if sddsrvyr in (9,10); run; proc format; value agef 1="20-39" 2="40-59" 3="60+" 0,-2="Adults" ; value sexf 1="Men" 2="Women" 0,-2="All" ; value racenamef 1="Non-Hispanic white" 2="Non-Hispanic black" 3="Non-Hispanic Asian" 4="Hispanic" 5="NH Other/Multiple races" -2=" " 0="All" ; value raceshortf 1="NHW" 2="NHB" 3 ="NHA" 4="HSP" 5="Oth" -2 = " " ; value svyyrf 1="1999-2000" 2="2001-2002" 3="2003-2004" 4="2005-2006" 5="2007-2008" 6="2009-2010" 7= "2011-2012" 8= "2013-2014" 9= "2015-2016" 10= "2017-2018" 0,-2=" " ; value outcomef 1="anyOpioid" 2="NonOpioidOnly" 3="anyPainMed" ; value sexPairsF 1="Men vs. women" ; value agePairsF 1="20-39 vs. 40-59" 2="20-39 vs. 60+" 3="40-59 vs. 60+" ; run; * define format to label pairwise contrasts for race and Hispanic origin *; data _racePairFmt; length label $20; fmtname="racePairsF"; start=0; nCats=5; do i = 1 to (nCats-1); do j = i+1 to nCats; start+1; label=compbl(put(i, raceshortf.) || " vs. " || put(j, raceshortf.)); output; drop i j nCats; end; end; run; proc format library=work cntlin=_racePairFmt; run; ********************************************************************; *PROPORTIONS**; ********************************************************************; * this method estimates the proportion as the mean of a 0/100 indicator variable *; Title "Figure 1. Use of prescription pain medications in the past 30 days among adults aged 20 and over, by sex and age: United States, 2015–2018"; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR atlevel1=1 atlevel2=2 /*noprint*/ ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr ageCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyPainMed ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 riagendr*ageCat; rformat riagendr sexf.; rformat ageCat agef.; print nsum mean semean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean atlev1 atlev2 /filename=fig1 meanfmt=f6.1 semeanfmt=f6.1 replace; rtitle "Figure 1. Use of prescription pain medications in the past 30 days among adults aged 20 and over, by sex and age: United States, 2015–2018"; run; * Call macro to calculate Korn and Graubard confidence intervals *; %calculate_KornGraubard_CIs; proc print data=fig1_KG noobs label; var riagendr ageCat nsum percent sepercent lowerCL upperCL; footnote "Confidence limits are calculated by the method of Korn and Graubard using the calculate_KornGraubard_CIs macro"; run; *******************************************************************************************; **ALTERNATIVE***** ** Korn and Graubard confidence intervals **; *NOTE: Mean and SEmean are specified, based on the output statement above*** *** NOTE: this code is not appropriate for age-standardized proportions *** *******************************************************************************************; proc format; value varlabel 1="anypainmed" ; run; data fig1; set fig1; *p and its standard error should be decimal numbers between 0 and 1 ; p=mean/100; sep=semean/100; * complementary proportion *; q=1-p; df_flag=0; df=atlev2-atlev1; if df<8 then df_flag=1; * Effective sample size *; if (0 0 then rat_squ=(tinv(.975,nsum-1)/tinv(.975,df))**2; else rat_squ=0; *limit case: set to zero; *df-adjusted effective sample size (can be no greater than the sample size); if p > 0 then n_eff_df=min(nsum,rat_squ*n_eff); else n_eff_df=nsum; *limit case: set to sample size; *Parameters for beta confidence limits; x=n_eff_df*p; v1=x; v2=n_eff_df-x+1; v3=x+1; v4=n_eff_df-x; *lower and upper confidence limits for Korn and Graubard interval ; * Note: Using inverse beta instead of ratio of Fs for numerical efficiency ; *if (00) then kg_relw_p=100*(kg_wdth/p); else kg_relw_p=.; *Korn and Graubard CI relative width for q; if (q>0) then kg_relw_q=100*(kg_wdth/q); else kg_relw_q=.; * Application of the NCHS Data Presentation Standards for Proportions *; *Proportions with CI width <= 0.05 are reliable, unless...; p_reliable=1; *...effective sample size or nominal sample size is less than 30; if min(nsum, n_eff) < 30 then p_reliable=0; *...absolute CI width is greater than or equal 0.30; else if kg_wdth ge 0.30 then p_reliable=0; *...relative CI width is greater than 130%; else if (kg_relw_p > 130 and kg_wdth > 0.05) then p_reliable=0; *Determine if estimate should be flagged as having an unreliable complement; if (p_reliable=1) then do; *Complementary proportions are reliable, unless...; q_reliable=1; *...relative CI width is greater than 130% ; if (kg_relw_q > 130 and kg_wdth > 0.05) then q_reliable=0; end; *Determine if estimate should be flagged for statistical review ; p_statistical=0; if p_reliable=1 then do; *Estimates with df < 8 or percents = 0 or 100 or unreliable complement are flagged for clerical or ADS review; if df_flag=1 or p=0 or p=1 or q_reliable=0 then p_statistical =1; end; format variable varlabel.; run; proc print data=fig1 noobs label; var riagendr ageCat nsum p sep q kg_l kg_u p_reliable q_reliable p_statistical; format p sep q kg_l kg_u 8.3; footnote "Confidence limits are calculated by the method of Korn and Graubard using alternative example code"; run; title; footnote; ********************************************************; * T-tests for pairwise comparisons by sex *; ********************************************************; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR /*noprint*/ ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr ageCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyPainMed ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 ageCat; * Pairwise statement: Requests all contrasts*; pairwise riagendr; rformat riagendr sexf.; rformat ageCat agef.; print nsum mean semean t_mean p_mean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean t_mean p_mean /filename=fig1_testSex meanfmt=f6.1 semeanfmt=f6.1 replace; run; ********************************************************; * Analysis of trends by age using Logistic Regression *; ********************************************************; * all adults *; proc rlogist data = Rx FILETYPE = SAS DESIGN = WR ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s). Reflevel statement can be included to choose reference category for the categorical variables. By default SUDAAN uses the highest category*; class one /nofreq; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; subpopx inAnalysis; * Model statement: specifies dependent variable and independent variable(s) *; MODEL anyPainMed = ageCat; * Output statement: outputs the results to a file*; output / betas=default filename=fig1_logistReg_betas_all replace; * Test statement: produces statistics and P values for the Satterthwaite adjusted CHI square (satadjchi), the Satterthwaite adjusted F (satadjf), and Satterthwaite adjusted degrees of freedom (printed by default). If this statement is omitted, the nominal degrees of freedom, the WALDF and the p-value corresponding to the WALDF and WALDP will be produced.*; test waldf satadjf satadjchi; run; * age trend by sex *; proc rlogist data = Rx FILETYPE = SAS DESIGN = WR ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s). Reflevel statement can be included to choose reference category for the categorical variables. By default SUDAAN uses the highest category*; class one riagendr /nofreq; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; subpopx inAnalysis; rby riagendr; * Model statement: specifies dependent variable and independent variable(s) *; MODEL anyPainMed = ageCat; * Output statement: outputs the results to a file*; output / betas=default filename=fig1_logistReg_betas_sex replace; * Test statement: produces statistics and P values for the Satterthwaite adjusted CHI square (satadjchi), the Satterthwaite adjusted F (satadjf), and Satterthwaite adjusted degrees of freedom (printed by default). If this statement is omitted, the nominal degrees of freedom, the WALDF and the p-value corresponding to the WALDF and WALDP will be produced.*; test waldf satadjf satadjchi; run; ***********************************************************; *PROPORTIONS**; ***********************************************************; Title "Figure 2. Use of prescription pain medications in the past 30 days among adults aged 20 and over, by sex and race and Hispanic origin: United States, 2015–2018"; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR atlevel1=1 atlevel2=2 /*noprint*/; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyPainMed ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 riagendr*raceEthCat; rformat riagendr sexf.; rformat raceEthCat racenamef.; print nsum mean semean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean atlev1 atlev2 /filename=fig2 meanfmt=f6.1 semeanfmt=f6.1 replace; rtitle "Figure 2. Use of prescription pain medications in the past 30 days among adults aged 20 and over, by sex and race and Hispanic origin: United States, 2015–2018"; run; ********************************************************; * T-tests for pairwise comparison by sex *; ********************************************************; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR /*noprint*/ nomarg ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyPainMed ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 raceEthCat; * Pairwise statement: Requests all contrasts*; pairwise riagendr; rformat riagendr sexf.; rformat raceEthCat racenamef.; print nsum mean semean t_mean p_mean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean t_mean p_mean /filename=fig2_testSex meanfmt=f6.1 semeanfmt=f6.1 replace; run; ********************************************************; * T-tests for pairwise comparisons by race and Hispanic origin*; ********************************************************; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR /*noprint*/; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyPainMed ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 riagendr ; * Pairwise statement: Requests all contrasts*; pairwise raceEthCat; rformat riagendr sexf.; rformat raceEthCat racenamef.; print nsum mean semean t_mean p_mean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean t_mean p_mean /filename=fig2_testRace meanfmt=f6.1 semeanfmt=f6.1 replace; run; ******************************************************************; *PROPORTIONS**; ******************************************************************; Title "Figure 3. Use of prescription opioids in the past 30 days among adults aged 20 and over, by sex, age, and race and Hispanic origin: United States, 2015–2018"; PROC DESCRIPT DATA = rx FILETYPE = SAS DESIGN = WR atlevel1=1 atlevel2=2 /*noprint*/ nomarg ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specifies categorical variable(s)*; class one riagendr ageCat raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyOpioid ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 one riagendr ageCat raceEthCat ; rformat riagendr sexf.; rformat ageCat agef.; rformat raceEthCat racenamef.; print nsum mean semean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean atlev1 atlev2 /filename=fig3 meanfmt=f6.1 semeanfmt=f6.1 replace; rtitle "Figure 3. Use of prescription opioids in the past 30 days among adults aged 20 and over, by sex, age, and race and Hispanic origin: United States, 2015–2018"; run; ********************************************************; * T-tests for pairwise comparisons by sex and race and Hispanic origin *; ********************************************************; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR /*noprint*/ nomarg ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr ageCat raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyOpioid ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 one ; * Pairwise statement: Requests all contrasts*; pairwise riagendr; pairwise raceEthCat; rformat riagendr sexf.; rformat raceEthCat racenamef.; print nsum mean semean t_mean p_mean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean t_mean p_mean /filename=fig3_tests meanfmt=f6.1 semeanfmt=f6.1 replace; run; ********************************************************; *Linear trends analysis by age group using Logistic Regression*; ********************************************************; proc rlogist data = Rx FILETYPE = SAS DESIGN = WR ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s). Reflevel statement can be included to choose reference category for the categorical variables. By default SUDAAN uses the highest category*; class one /nofreq; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; subpopx inAnalysis; * Model statement: specifies dependent variable and independent variable(s) *; MODEL anyOpioid = ageCat; * Output statement: outputs the results to a file*; output / betas=default filename=fig3_logistReg_betas_all replace; * Test statement: produces statistics and P values for the Satterthwaite adjusted CHI square (satadjchi), the Satterthwaite adjusted F (satadjf), and Satterthwaite adjusted degrees of freedom (printed by default). If this statement is omitted, the nominal degrees of freedom, the WALDF and the p-value corresponding to the WALDF and WALDP will be produced.*; test waldf satadjf satadjchi; run; ****************************************************************; *PROPORTIONS**; ****************************************************************; title "Figure 4. Prescription non-opioid (only) pain medication use among adults aged 20 and over, by sex, age, and race and Hispanic origin: United States, 2015-2018"; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR atlevel1=1 atlevel2=2 /*noprint*/ nomarg ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr ageCat raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR NonOpioidOnly ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 one riagendr ageCat raceEthCat ; rformat riagendr sexf.; rformat ageCat agef.; rformat raceEthCat racenamef.; print nsum mean semean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean atlev1 atlev2 /filename=fig4 meanfmt=f6.1 semeanfmt=f6.1 replace; rtitle "Figure 4. Prescription non-opioid (only) pain medication use among adults aged 20 and over, by sex, age, and race and Hispanic origin: United States, 2015-2018"; run; ********************************************************; * T-tests for pairwise comparisons by sex and race and Hispanic origin *; ********************************************************; PROC DESCRIPT DATA = Rx FILETYPE = SAS DESIGN = WR /*noprint*/ nomarg ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class one riagendr ageCat raceEthCat /nofreq; * Var statement: specify the analysis variable(s)*; VAR NonOpioidOnly ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 one ; * Pairwise statement: Requests all contrasts*; pairwise riagendr; pairwise raceEthCat; rformat riagendr sexf.; rformat ageCat agef.; rformat raceEthCat racenamef.; print nsum mean semean t_mean p_mean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean t_mean p_mean /filename=fig4_tests meanfmt=f6.1 semeanfmt=f6.1 replace; run; ********************************************************; * Linear trends analysis by age group using logistic regression *; ********************************************************; proc rlogist data = Rx FILETYPE = SAS DESIGN = WR ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s). Reflevel statement can be included to choose reference category for the categorical variables. By default SUDAAN uses the highest category*; class one /nofreq; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; subpopx inAnalysis; * Model statement: specifies dependent variable and independent variable(s) *; MODEL NonOpioidOnly = ageCat; * Output statement: outputs the results to a file*; output / betas=default filename=fig4_logistReg_betas_all replace; * Test statement: produces statistics and P values for the Satterthwaite adjusted CHI square (satadjchi), the Satterthwaite adjusted F (satadjf), and Satterthwaite adjusted degrees of freedom (printed by default). If this statement is omitted, the nominal degrees of freedom, the WALDF and the p-value corresponding to the WALDF and WALDP will be produced.*; test waldf satadjf satadjchi; run; ****************************************************************; *PROPORTIONS***; ****************************************************************; title "Figure 5. Prescription opioid and non-opioid pain medication use among adults aged 20 and over: United States, 2009-2010 through 2017-2018"; PROC DESCRIPT DATA = sp_level FILETYPE = SAS DESIGN = WR atlevel1=1 atlevel2=2 /*noprint*/ nomarg; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s)*; class sddsrvyr /nofreq; * Var statement: specify the analysis variable(s)*; VAR anyOpioid NonOpioidOnly ; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; SUBPOPX inAnalysis; * 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 ; rformat sddsrvyr svyyrf.; print nsum mean semean /style=nchs meanfmt=f6.1 semeanfmt=f6.1 ; output nsum mean semean atlev1 atlev2 /filename=fig5 meanfmt=f6.1 semeanfmt=f6.1 replace; rtitle "Figure 5. Prescription opioid and non-opioid pain medication use among adults aged 20 and over: United States, 2009-2010 through 2017-2018"; run; ********************************************************; * Linear trends analysis by survey cycle using logistic regressions*; ********************************************************; %macro testTrend(outcome); * linear trend *; proc rlogist data = sp_level FILETYPE = SAS DESIGN = WR ; * Nest statement: PSUs nested within Strata accounts for the design effects*; NEST SDMVSTRA SDMVPSU / MISSUNIT; * Weight statement: specify appropriate weight, accounts for the unequal probability of sampling and non-response.*; WEIGHT wtint2yr; * Class statement: specify categorical variable(s). Reflevel statement can be included to choose reference category for the categorical variables. By default SUDAAN uses the highest category*; class one /nofreq; * Subpopx statement: specify the subpopulation of interest (the inclusion criteria)*; subpopx inAnalysis; * Model statement: specifies dependent variable and independent variable(s) *; MODEL &outcome = sddsrvyr_start09; * Output statement: outputs the results to a file*; output / betas=default filename=fig5_linear_&outcome. replace; * Test statement: produces statistics and P values for the Satterthwaite adjusted CHI square (satadjchi), the Satterthwaite adjusted F (satadjf), and Satterthwaite adjusted degrees of freedom (printed by default). If this statement is omitted, the nominal degrees of freedom, the WALDF and the p-value corresponding to the WALDF and WALDP will be produced.*; test waldf satadjf satadjchi; run; * quadratic trend *; proc rlogist data = sp_level FILETYPE = SAS DESIGN = WR ; NEST SDMVSTRA SDMVPSU / MISSUNIT; WEIGHT wtint2yr; class one /nofreq; subpopx inAnalysis; MODEL &outcome = sddsrvyr_start09 sddsrvyr_start09_sq; output / betas=default filename=fig5_quad_&outcome. replace; test waldf satadjf satadjchi; run; %mend testTrend; %testTrend(anyOpioid); %testTrend(NonOpioidOnly); data fig5_betas; set fig5_linear_anyOpioid fig5_quad_anyOpioid fig5_linear_NonOpioidOnly fig5_quad_NonOpioidOnly indsname=dsn ; length type $6 outcome $15; type= scan (dsn, 3, "._"); outcome= scan (dsn, 4, "._"); if (type="LINEAR" and modelRHS=2) or (type="QUAD" and modelRHS=3); run;