Previous Chapter: Appendix G: Perspectives from the Department of Veterans Affairs Pain/Opioid Consortium on Research Veteran Engagement Panel
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.

H

Approach to Data Analysis and Code Library

INTRODUCTION

The following describes the approach to the data analysis conducted by the committee for the following studies: Study 1 (opioid initiation among those with and without current benzodiazepine fill), studies 2a and 2b (opioid baseline, dose escalation), and study 3 (benzodiazepine initiation among those on long-term opioid pharmacotherapy). Westat, the subcontractor, had access to the data and analyzed the data available through outlined sources. All analyses were conducted using SAS 9.4 and SAS Enterprise Guide.

The following describes the data sources used for the analyses, including covariates, and overall approach to constructing the analytic data files.

Data Sources

Per data use agreements with Veterans Health Administration (VHA), Westat obtained access to health record data from VHA CDW and Centers for Medicare & Medicaid Services (CMS) Medicare files. VHA CDW provided a snapshot of medical records in the VA Informatics and Computing Infrastructure (VINCI) workspace, and the database tables within VINCI were linked using unique individual identifiers assigned by the VHA (PatientICN). CMS datafiles were provided in the database as SAS datasets and linked to VHA medical records by Social Security number (SSN). Death data for SSNs in the VINCI extract were obtained from National Death Index files per an internal request to the Joint Department of Veterans Affairs (VA) and Department of Defense Mortality Data Repository Data team and added back to the veteran record using the SSN.

Only the subcontractor had access to personally identifiable health information and personally identifiable information; all access to the data and analyses occurred within the VA firewall and data ecosystems. All analyses were also conducted within the VA firewall, and the final analytic aggregated results were removed from VINCI to provide to the committee only after privacy review. All approved data analysts who worked on this study were also subject to a VA background check, maintained up-to-date human subjects training, and worked within Westat’s designated workspace on the server. The National Academies of Sciences, Engineering, and Medicine (National Academies) Institutional Review Board approved the study. Study results do not report data if sample sizes were 10 or fewer individuals. This helps to ensure confidentiality of individuals in the study and is in line with CMS data

Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.

policy and the National Center for Health Statistics (NCHS) recommendations.1,2 Furthermore, cells are marked as unreliable where sample sizes were 20 or fewer.

Covariates

Prescription data were obtained from both VHA outpatient prescriptions and CMS Medicare provided Part D claims. Drug list lookup tables were used to identify valid opioid prescriptions that were filled (picked up) from the VHA and CMS.

All diagnostic specific covariates were derived using a valid ICD-9 or ICD-10 code from either VHA CDW or CMS files. For example, veterans with an end stage renal disease (ESRD) code in VHA files, CMS files, or both would be coded as having ESRD.

Demographic variables were obtained from VHA. For some demographics, such as age and marital status, the record closest to the veteran study start date was used. Other demographics were based on all records such as sex, race, and ethnicity.

Overall Approach to Analytic Files

Westat obtained records for any patients with an encounter in the VHA between 2005 and 2020. Data extraction, preparation, cleaning, and transformation of the billions of VHA records was necessary to eventually create the final study analysis datasets.

The first data prep step was to identify eligible veterans for the study (i.e., all study groups). Westat applied inclusion and exclusion criteria approved by the National Academies committee along with VHA best practice to drop suspect records (e.g., test cases and bad SSNs). The next step involved identifying veterans prescribed the main drugs of interest at any time, which involved a manual step of reviewing all the VHA drug codes to flag the drugs of interest and then linking that reference file back to the VHA prescription data.

After identifying eligible veterans and an extract on their drug use, a sample frame was created for each of the studies based on the committee criteria (e.g., no drug use before first study month). A veteran may appear multiple times in the sample frame with different episodes of drug use. For study 1, a random episode is retained for each veteran. For study 2, the first episode is retained for each veteran. For study 3, all veteran episodes are retained, given the much smaller sample size for analysis. Using the selected sample, covariates are pulled from the VHA and CMS medical records then assigned in reference to the veteran’s first study month in the episode (e.g., veteran age, heart disease in past 12 months) and put into an analytic dataset.

Quality Control Process

Westat followed committee defined protocol to define study specific sample populations and conduct analyses. The lead researcher drafted initial specifications for the programmers to implement based on committee decisions. Iterations of the study protocol were implemented and made with committee consent. Upon completing analysis, Westat drafted results memos to share with the committee that included methodologic and programming notes where appropriate. The lead analyst and programmer wrote the memos, with one serving as the primary writer and the other in a quality control (QC) role. The results were also reviewed by the project director for quality control and privacy review processes.

SAS PROGRAMS:

An extensive number of scripts were written for this study and can be grouped by purpose. Tables H-1 and H-2 contain each script along with its name and purpose.

___________________

1 U.S. Department of Health and Human Services. 2020. CMS Cell Suppression Policy. https://www.hhs.gov/guidance/document/cms-cell-suppression-policy (accessed September 19, 2024).

2 National Center for Health Statistics. 2023. Underlying Cause of Death 1999-2020. https://wonder.cdc.gov/wonder/help/ucd.html#Source (accessed August 24, 2024).

Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
  1. Data Extraction and Transformation—veteran demographics and covariates were extracted from CDW and CMS, and they were saved to SAS datasets to later be used in assembling the analytic datasets. The team manually created ICD and Diagnosis reference files that were used by the scripts
    1. Demographic Variables
    2. Drug Variables
    3. Covariates defined by diagnostic codes
      1. Lookup tables
  2. Identifying Eligible Veterans
    1. Inclusion/Exclusion
  3. Creating Study 1 Analysis Data Sets
    1. Sample Frame
    2. Random sampling
    3. Creation of Analytic Files—Linkage of VHA, NDI and CMS files
    4. Fixes to code—additional derived variables
    5. Main analysis
    6. Sensitivity Analysis
  4. Creating Study 2 Analysis Data Sets
    1. Sample Frame
    2. Sampling - First eligible episode
    3. Creation of Analytic Files—Linkage of VHA, NDI and CMS files
    4. Main analysis
    5. Bootstrap for main analysis to produce confidence intervals
    6. Sensitivity Analysis
  5. Creating Study 3 Analysis Data Sets
    1. Sample Frame
    2. Sampling
    3. Creation of Analytic Files—Linkage of VHA, NDI and CMS files
    4. Main analysis
    5. Sensitivity Analysis

DATA PREPARATION PROGRAMS3

Table H-1 Data Preparation Programs

Folder Program Purpose
1_Eligible Veterans
Define Eligible Gasper Cohort.sas Clean the CDW Spatient table by removing invalid SSNs, SSNs associated with different PatientICN and vice versa,
VeteranFlag = N, test patients, vets deceased before 2006, birth year 1907–2001
2_CDW Extract
ADR_Enroll.sas Extract ADR Enrollment data from CDW
BMI.sas Extract vital signs data on height and weight and calculate body mass index
Ever Demographics.sas Extract veteran demographics from CDW
FindDrug_GABAPENTIN.sas Extract drug prescription data from CDW
FindDrug_Opioid.sas Extract drug prescription data from CDW
FindDrug_RF_032024.sas
FindDrugs.sas Extract drug prescription data from CDW
Hospice.sas Identify and extract hospice diagnosis (DX) records from CDW

___________________

3 Note: Study 1 is referred to as trial 1, 4, and 5. Study 2 is referred to as trial 2. Study 3 is referred to as trial 3.

Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
Inpatient Hospital Admission.sas Identify and extract inpatient hospital admission DX records from CDW
Insurance.sas Identify and extract insurance DX records from CDW
Nonmelanoma Cancer.sas Identify and extract non-melanoma cancer DX records from CDW
NursingHomeAdmission.sas Identify and extract nursing home admission DX records from CDW
painscore.sas Extract veteran pain scores from CDW
preindexDx ICD9.sas Identify and extract ICD9 DX records from CDW
preindexDx ICD10.sas Identify and extract ICD10 DX records from CDW
preindexDx2 ICD9.sas Identify and extract ICD9 DX records from CDW for diagnoses where two or more occurrences is of interest
preindexDx2 ICD10.sas Identify and extract ICD10 DX records from CDW for diagnoses where two or more occurrences is of interest
Skin Cancer.sas Identify and extract skin cancer DX records from CDW
sleep DX.sas Identify and extract sleep DX records from CDW
Trial2 exclusions.sas
VA first encounter.sas Identify and extract veterans first VHA encounter from CDW
VA_birth_marital.sas Extract veteran demographics from CDW
VHA_Drug_Reference_Flags_2_14_24.xlsx Reference file containing VA drug primary keys (SIDs) with flags to assign them to National Academies drug category
VHA_Drug_Reference_Flags_2_23_24.xlsx (UPDATED) Reference file containing VA drug primary keys (SIDs) with flags to assign them to National Academies drug category
VHA_Drug_Reference_Flags_3_11_24.xlsx (UPDATED) Reference file containing VA drug primary keys (SIDs) with flags to assign them to National Academies drug category
VHA_Drug_Reference_Flags_3_20_24.xlsx (UPDATED) Reference file containing VA drug primary keys (SIDs) with flags to assign them to National Academies drug category
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
3_CMS Extract
Add PatientICN to CMS files.sas Add VA PatientSID identifier to CMS covariate data.
Add PatientICN to CPT_AcutePainfulInjury.sas Add VA PatientSID identifier to CMS covariate data.
Add PatientICN to PalliativeCare_NonMelanomaCancers.sas Add VA PatientSID identifier to CMS covariate data.
CMS drug benzo06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_ACETAMIN06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_Antidepressant06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_BUPREN06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_BUSPIRONE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_CARBAMAZEPINE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_Confounder06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_FullAgonistOpioid06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_GABAPENTIN06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_HYDROXYZINE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_Insomnia06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_LIQUID_LAAM06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_LTOT06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_METHADONE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_Migraine06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_MIRTAZAPINE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_MuscleRelaxer06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_NALTREXONE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_nonopioids06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_opioids06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
CMS drug_OXCARBAZEPINE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_PartialAgonistOpioid06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_PREGABALIN06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_TOPIRAMATE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS drug_VENLAFAXINE06_19.sas Extract drug prescription data from 2006 to 2019 CMS files
CMS_Drug_Reference_Flags_2_14_24.xlsx Reference file containing CMS drug names with flags to assign them to National Academies drug category
CMS_Drug_Reference_Flags_3_20_24.xlsx Reference file containing CMS drug names with flags to assign them to National Academies drug category
Add PatientICN to Covariates_7Files.sas Add VA PatientSID identifier to CMS covariate data.
Add PatientICN to CovariatesFiles.sas Add VA PatientSID identifier to CMS covariate data.
Add PatientICN to Pain_DXFiles.sas Add VA PatientSID identifier to CMS covariate data.
4_NDI
S1. Attach PatientICN to NDI and suicide flag.sas Attach VA person ID to NDI returned results and create flag identify mortality cause associated with suicide codes
5_Determine Episodes| Trial 2
1. Opioid Episode Sample Frame.sas To identify eligible episodes for veterans using opioids and create a sample frame.
2. Find First Episode with MME below 50_20240301.sas OLD/DEPRECATED—Merge on monthly MME data to veteran episode sample and flag veteran episodes with their baseline monthly MME (opioid dosage) to identify eligible episodes and create descriptive statistics.
2. Find First Episode with MME below 50_20240301.sas Merge on monthly MME data to veteran episode sample and flag veteran episodes with their baseline monthly MME (opioid dosage) to identify eligible episodes and create descriptive statistics.
4. Build Veteran Episode Month Arrays.sas To build a veteran episode month array for the veteran episodes. Note: Trial 2 did not sample, so a veteran may appear multiple times in analysis datasets.
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
5_Determine Episodes| Trial 3
1. Benzo Episode Sample Frame.sas To identify eligible episodes for veterans using benzodiazepines and create a sample
frame.
2. Insomnia or Antidepressant Episode Sample Frame.sas To identify eligible episodes for veterans using insomnia or antidepressants and create a sample frame.
3. Sample Veteran Episodes (Trial3).sas To identify episodes where veterans used both insomnia and antidepressants, describe the frequency of this, and create a random sample of episodes (later decided to use a census of eligible episodes without sampling)
4. Build Veteran Episode Month Arrays.sas To build a veteran episode month array for the sampled veteran episodes
5_Determine Episodes| Trial4 (updated analytic sampling frame but reference Trial 1)
1. Opioid Episode Sample Frame.sas To identify eligible episodes for veterans using opioids and create a sample frame
2. NonOpioid Episode Sample Frame.sas To identify eligible episodes for veterans using nonopioids and create a sample frame
3. Sample Veteran Episodes (Trial4).sas To identify episodes where veterans used both opioids and nonopioids, describe the frequency of this, and create a random sample of episodes
4. Build Veteran Episode Month Arrays.sas To build a veteran episode month array for the sampled veteran episodes
6_Create Data Sets | Trial2
0.10 Ever and TM0 Demographics T2.sas Create analysis dataset containing veteran demographics and covariates related to first month in episode
0.15 Append new covariates to Demo T2.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.20 Time Series T2.sas Create analysis dataset contain veteran-episode-months and various flags per month
0.25 Append new covariates to Time Series T2.sas Add new covariates that the National Academies committee wants to the analysis time series dataset
0.251 Append new covariates to Time Series T2.sas Add new covariates that the National Academies committee wants to the analysis time series dataset
0.252 Append new covariates to Time Series T2.sas Add new covariates that the National Academies committee wants to the analysis time series dataset
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
T2_EPISODES_FIRSTUNDER50_MMEs.sas Construct Trial 2 timeseries opioid MME dataset; examine the result of censoring episodes based on MME values and opioid discontinuation
1.0 T2 Episodes.sas OLD/DEPRECATED—This was Chris pointing Sherrie to some MME merging code from 5_Determine Episodes\Trial2\2. Find First Episode with MME below 50_20240301.sas
1.0 T2 Episodes_V3.sas Construct flags and outcome measures for T2 analysis dataset in preparation for G-formula macro; censor veteran episodes when they cease opioid use for 3 consecutive months Examine and QC variable distributions
1.0 T2 Episodes_V4.sas Update from previous 1.0 T2 Episodes_ V3.sas code file—add/create lagged covariates for benzodiazepine use and pain score from the month before veteran episode baseline
6_Create Data Sets | Trial3
0.10 Ever and TM0 Demographics.sas Create analysis dataset containing veteran demographics and covariates related to first month in episode
0.15 Append new covariates to Demo T3.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.151 Append new covariates to Demo T3.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.152 Append new covariates to Demo T3.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.20 Time Series T3.sas Create analysis dataset contain Veteran-Episode-Months and various flags per month
0.25 Append new covariates to Time Series T3.sas Add new covariates that the National Academies committee wants to the analysis time series dataset
1b. NDI Unadjusted Analysis—t3.sas (QC/Exploratory) Import date and reason of death from NDI dataset to construct outcome measures, examine distribution, and produce preliminary analysis output for QC
2. Analysis Data.sas Create final analysis covariates, produce IPTW, reshape data to the episode-month level, create outcome measures, and finalize Trial 3 analysis dataset, output QC materials and descriptive statistics
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
2. Analysis Data_0709.sas Update to previous file—2; analysis Data.sas—Episodes with simultaneous initiation of benzodiazepine and insomnia/antidepressant use excluded
3. Analysis of Expanded Time Series T3.sas (UNUSED/Exploratory); exploratory method of removing the overlapping portion of 12-month-duration episodes for upcoming sensitivity analysis
9a. Adhoc—BenzoSupply in TM0.sas Ad hoc request to extract benzodiazepine day supply for month TM0
6_Create Data Sets | Trial4 (Trial 1)
0.10 Ever and TM0 Demographics.sas Create analysis dataset containing veteran demographics and covariates related to first month in episode
0.15 Append new covariates to Demo T4.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.151 Append new covariates to Demo T4.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.152 Append new covariates to Demo T4.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.153 Append new covariates to Demo T4.sas Add new covariates that the National Academies committee wants to the analysis demographics dataset
0.20 Time Series.sas Create analysis dataset contain veteran-episode-months and various flags per month
0.25 Append new covariates to Time Series T4.sas Add new covariates that the National Academies committee wants to the analysis time series dataset
1b. NDI Unadjusted Analysis—t4.sas (QC/Exploratory) Import date and reason of death from NDI dataset to construct outcome measures, examine distribution, and produce preliminary analysis output for QC
T4_TimeSeries_MMEs.sas Construct monthly time series opioid MME dataset for Trial 4 analysis dataset
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
2. Analysis Data.sas Beginning from same sample of episodes used in Trial 1, treatment arms are Opioid+Benzo vs. Opioid+NoBenzo; create final analysis covariates, produce IPTW, reshape data to the episode-month level, create outcome measures, and finalize Trial 4 analysis dataset Output QC materials and descriptive statistics
6_Create Data Sets | Trial5 (Additional Update to Trial 4/Trial 1 Specifications)
2. Analysis Data.sas Beginning from same sample of episodes used in Trial 1, treatment arms are Opioid vs. NonOpioid in two stratified cohorts—5a: NonBenzo and 5b: benzo; create final analysis covariates, produce IPTW (per protocol weights are produced in separate monthly slices), reshape data to the episode-month level, create outcome measures, and finalize Trial 5a and 5b analysis datasets, output QC materials and descriptive statistics
9_MME
Opioid MME_RF_20240214.sas Import drug flags and drug strength values, merge onto veteran RX data to calculate monthly opioid MME
Opioid MME_RF_20240223.sas (UPDATED) Import drug flags and drug strength values, merge onto veteran RX data to calculate monthly opioid MME
Opioid MME_RF_20240227.sas (UPDATED) Import drug flags and drug strength values, merge onto veteran RX data to calculate monthly opioid MME
CDW Opioid MME_outliers_QC_20240227.sas (QC) Examine veteran episodes with unreasonable MME values
Opioid MME_RF_20240304.sas (UPDATED) Import drug flags and drug strength values, merge onto veteran RX data to calculate monthly opioid MME
Opioid MME_OutlierEpisodes_20240311.sas (QC) Examine veteran episodes with unreasonable MME values
Opioid MME_OutlierDrugs_20240311.sas (QC) Examine drugs with unreasonable MME values
Build_Opioid_MME_Lookup_20240318.sas Construct lookup table of monthly veteran MME dosage used in later dataset construction steps
G-formula (Trial 2)
gformula4.0.sas Download from online
DeathMainAnalyses_0-20_20-40\
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
Gformula_data_derived_FlagVar.sas derived flags variables
g_DeathOutcome_allvars_flagb1.sas with bootstrap (n = 5)
g_DeathOutcome_allvars_flagb5.sas with bootstrap (n = 5)
g_DeathOutcome_allvars_flagb1_V2.sas
g_DeathOutcome_allvars_flagb2_V2.sas
g_DeathOutcome_allvars_flagb3_V2.sas
g_DeathOutcome_allvars_flagb4_V2.sas
g_DeathOutcome_allvars_flagb5_V2.sas
Opioid MME_OutlierDrugs_20240311.sas
DeathSensitivityAnalyses\
Gformula_data_derived_FlagVar_SensitivityAnalyses.sas derived new flags, based on SensitivityAnalyses tables (0–40, 40–50)
g_DeathOutcome_Sensitivity_flagb1_V2.sas
g_DeathOutcome_Sensitivity_flagb2_V2.sas
g_DeathOutcome_Sensitivity_flagb3_V2.sas
g_DeathOutcome_Sensitivity_flagb4_V2.sas
g_DeathOutcome_Sensitivity_flagb5_V2.sas
g_DeathOutcome_Sensitivity_flagb1.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb2.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb3.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb4.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb5.sas with bootstrap (n = 5)
DeathSensitivityAnalyses_flagb3\
Gformula_data_derived_FlagVar_SensitivityAnalyses.sas
g_DeathOutcome_Sensitivity_flagb1_V2.sas
g_DeathOutcome_Sensitivity_flagb2_V2.sas
g_DeathOutcome_Sensitivity_flagb3_V2.sas
g_DeathOutcome_Sensitivity_flagb4_V2.sas
g_DeathOutcome_Sensitivity_flagb5_V2.sas
g_DeathOutcome_Sensitivity_flagb1.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb2.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb3.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb4.sas with bootstrap (n = 5)
g_DeathOutcome_Sensitivity_flagb5.sas with bootstrap (n = 5)
DeathSensitivityAnalyses_flagb3\ based on SensitivityAnalyses tables (0-40, 40-50)
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
g_Out0_50_flaga6_0_20.sas Produce estimates and standard errors for
g_Out0_51_flaga6_20_50.sas 400 bootstrap estimates
g_Out0_52_flaga6_40_50.sas
g_Out51_100_flaga6_0_20.sas
g_Out52_101_flaga6_20_50.sas
g_Out53_102_flaga6_40_50.sas
g_Out101_150_flaga6_0_20.sas
g_Out102_151_flaga6_20_50.sas
g_Out103_152_flaga6_40_50.sas
g_Out151_200_flaga6_0_20.sas
g_Out152_201_flaga6_20_50.sas
g_Out153_202_flaga6_40_50.sas
g_Out201_250_flaga6_0_20.sas
g_Out202_251_flaga6_20_50.sas
g_Out203_252_flaga6_40_50.sas
g_Out251_300_flaga6_0_20.sas
g_Out252_301_flaga6_20_50.sas
g_Out253_302_flaga6_40_50.sas
g_Out301_350_flaga6_0_20.sas
g_Out302_351_flaga6_20_50.sas
g_Out303_352_flaga6_40_50.sas
g_Out351_400_flaga6_0_20.sas
g_Out352_400_flaga6_20_50.sas
g_Out353_400_flaga6_40_50.sas
g_Out0_53_flag6b_Fast.sas
g_Out54_103_flag6b_Fast.sas
g_Out104_153_flag6b_Fast.sas
g_Out154_203_flag6b_Fast.sas
g_Out204_253_flag6b_Fast.sas
g_Out254_303_flag6b_Fast.sas
g_Out304_353_flag6b_Fast.sas
g_Out354_400_flag6b_Fast.sas
g_Out0_54_flag6b_Slow.sas
g_Out55_104_flag6b_Slow.sas
g_Out105_154_flag6b_Slow.sas
g_Out155_204_flag6b_Slow.sas
g_Out205_254_flag6b_Slow.sas
g_Out255_304_flag6b_Slow.sas
g_Out305_354_flag6b_Slow.sas
g_Out355_400_flag6b_Slow.sas
g_Out0_55_flag6b_Stable.sas
g_Out56_105_flag6b_Stable.sas
g_Out106_155_flag6b_Stable.sas
g_Out156_205_flag6b_Stable.sas
g_Out206_255_flag6b_Stable.sas
g_Out256_305_flag6b_Stable.sas
g_Out306_355_flag6b_Stable.sas
g_Out356_400_flag6b_Stable.sas
g_out_comb_flaga6_0_20.sas
g_out_comb_flaga6_40_50.sas
g_out_comb_flaga6_20_50.sas
g_out_comb_flagb6_Fast.sas
g_out_comb_flagb6_Slow.sas
g_out_comb_flagb6_Stable.sas
g_Sex_Male.sas
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
g_Sex_Female.sas
g_Race_Black.sas
g_Race_Asian.sas
g_Race_NativeAmerican.sas
g_Race_White.sas
g_Race_Hawaiian.sas
g_Race_Multi.sas
g_VHA only.sas
g_CMS only.sas
g_Dual_bothVHA_CMS.sas where VA_CMS_flag =“DUAL: both VHA and CMS”)
g_Ethnicity_Hispanic.sas
g_Ethnicity_Not_Hispanic.sas
g_Age_18_34.sas
g_Age_35_54.sas
g_Age_55_74.sas
g_Age_75_Plus.sas
g_Age_0_64.sas
g_Age_65_Plus.sas
g_StudyYear_2014_2020.sas
g_StudyYear_2007_2012.sas
g_data_flgOUDdx.sas Only apply: flgOUDdx=1 and nVEM=0 then delete
Censoring: RxMonth=. (3 mons), flgCancer=1 or flgHospice=1
g_flgOUDdx_Yes.sas used data only apply RxMonth and (flgCancer or flgHospice); if flgOUDdx=1;
g_flgOUDdx_No.sas used data only apply RxMonth and (flgCancer or flgHospice); if flgOUDdx=0;
g_Ethnicity_Missing.sas
Bootstrap\
g_DeathOutcome_flaga6_0_20.sas 0-20, flaga6_cat=1, 20-40,flaga6_cat=2, 40-50, flaga6_cat=3
g_DeathOutcome_flaga6_20_50.sas ’20< MME <= 50’
g_DeathOutcome_flaga6_40_50 ’40< MME <= 50’
g_DeathOutcome_Sensitivity_flagb6_Fast.sas Derived flagb6_cat, Trajectory 10-20 Fast, intmax1=2
g_DeathOutcome_Sensitivity_flagb6_Slow.sas Derived flagb6_cat, Trajectory 5-10 Slow
g_DeathOutcome_Sensitivity_flagb6_Stable Derived flagb6_cat, Trajectory 0-5 Stable
g_DeathOutcome_Sensitivity_flagb6_Fast_edit.sas Derived flagb6_cat, Trajectory 10-20 Fast, intmin1=3
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.

DATA ANALYSIS PROGRAMS4

Table H-2 Data Analysis Programs

Folder Program Purpose
7_Analysis
Trial 1_ITT.sas Trial 1 (opioid vs. nonopioid) intent-to-treat (ITT) methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 1_PerProtocol.sas Trial 1 (opioid vs. nonopioid) per protocol methodology (censoring based on Rx adherence) – death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 3_ITT.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant vs. both) ITT methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 3_ITT_2cat.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant, with “both” included in benzodiazepine) ITT methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 3_ITT_update0709.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant, with “both” excluded from analysis) ITT methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 3_SA_macro.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant, with “both” excluded from analysis) ITT methodology (no censoring)—sensitivity analysis groupings, death rates, proportional hazard ratios
Trial 3_SA_macro_extendedTS.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant, with “both” excluded from analysis) ITT methodology (no censoring)—sensitivity analysis of 12-month episode duration, death rates, proportional hazard ratios
Trial 3_SA_macro_min5pill.sas Trial 3 (benzodiazepine vs. insomnia/antidepressant, with “both” excluded from analysis) ITT methodology (no censoring)—sensitivity analysis of at least five pills for benzodiazepine initiation, death rates, proportional hazard ratios
Trial 4_ITT.sas Trial 4 (opioid+benzo vs. opioid+nobenzo) ITT methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 4_PerProtocol.sas Trial 4 (opioid+benzo vs. opioid+nobenzo) per protocol methodology (censoring based on Rx adherence)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial 5_combo.sas Trial 1a/1b (opioid vs. nonopioid, stratified by benzo/nobenzo) ITT methodology (no censoring)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve

___________________

4 Note: Study 1 is referred to as trial 1, 4, and 5. Study 2 is referred to as trial 2. Study 3 is referred to as trial 3.

Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Folder Program Purpose
Trial 5_PerProtocol.sas Trial 1a/1b (opioid vs. nonopioid, stratified by benzo/nobenzo) per protocol methodology (censoring based on Rx adherence)—death rate, proportional hazard ratio, survival curve, time to discontinuation, cumulative incidence curve
Trial1SA_Adhoc—age by insurance.as Examine crosstabulation of veteran age by type of insurance/health system
AdHoc—death rate by year.sas Examine distribution of veteran deaths per year
SA_macro.sas Trial 1a/1b (opioid vs. nonopioid, stratified by benzo/nobenzo) per protocol methodology (censoring based on Rx adherence)—Sensitivity Analysis groupings, death rates, proportional hazard ratios
SA_macro_survcurve.sas Trial 1a/1b (opioid vs. nonopioid, stratified by benzo/nobenzo) per protocol methodology (censoring based on Rx adherence)—Sensitivity Analysis groupings, survival curve data
SurvCurvData.sas Trial 1a/1b (opioid vs. nonopioid, stratified by benzo/nobenzo), survival curve data for both ITT and per protocol
Bonferroni_p_values.sas Generate Bonferroni-Holm-adjusted p-values due to the multiple tests done through sensitivity analysis
Truncated_Weight_Rerun_macro_t1.sas Rerun Trial 1 main and sensitivity analyses with truncated weights (weights <1st% set to 1% value, >99th% set to 99th%)
Truncated_Weight_Rerun_macro_t3.sas Rerun Trial 3 main and sensitivity analyses with truncated weights (weights <1st% set to 1% value, >99th% set to 99th%)
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.

This page intentionally left blank.

Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 275
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 276
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 277
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 278
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 279
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 280
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 281
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 282
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 283
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 284
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 285
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 286
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 287
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 288
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 289
Suggested Citation: "Appendix H: Approach to Data Analysis and Code Library." National Academies of Sciences, Engineering, and Medicine. 2025. Veterans, Prescription Opioids and Benzodiazepines, and Mortality, 2007–2019: Three Target Trial Emulations. Washington, DC: The National Academies Press. doi: 10.17226/28584.
Page 290
Next Chapter: Appendix I: Covariate International Classification of Disease Code Table
Subscribe to Email from the National Academies
Keep up with all of the activities, publications, and events by subscribing to free updates by email.