Section Progress
0% Complete

Guided exercise 3. Running the HDPS macro

Run the HDPS macro, select 200 variables per dimension and the top 500 variables overall. First try doing this on your own. Reveal the example code below if you need a hint or want to check your work.

Example code: Running the HDPS macro (click to reveal)

%InitHDMacros (
               var_patient_id = ID,
                       var_exposure = exposure,
                       var_outcome = i_diab,
                       vars_demographic =  sex age,
               vars_predefined = 4_drug 4_diag htn cholest pvd chf loop,
               vars_ignore = <insert variables that will not be included, e.g. index date,...>,
                       top_n = 200,
                       k = 500,
                       path_temp_dir=%sysfunc(getoption(<insert path to a directory to store temporary files>)),
               path_jar_file=%quote(<insert file path>\pharmacoepi.jar),  
                       input_cohort = cohort,
                       input_dim1 = hosp_diag <insert name of the field containing the code of interest e.g. DIAG, proced,..> ,
                       input_dim2 = hosp_proc Proced      ,
                       input_dim3 = med_diag med_diag       ,
                       input_dim4 = med_proc TARIFF       ,
                       input_dim5 = dpin atc           ,
                           output_cohort = ps_cohort,
                           score_type_1=0,
                           score_type_2=0,
                           score_type_3=0,
                           score_type_4=1,
                           score_type_5=0,
                           result_diagnostic = variable_info
                      );

%DoHDVariableSelection;
%EstimateHDPS (ps_cohort);      

Notes:

A. In the example above, there are 3 macros:

%InitHDMacros (as the name implies, it initiates the macro and allows specifying input and output data and HDPS parameters),
%DoHDVariableSelection (performs variable selection based on their prevalence and potential bias), and
%EstimateHDPS (estimates PS based on the variables selected in the previous steps +- demographics and predefined variables).

B. This example runs the HDPS macro and produces HDPS for each individual. We can then use these propensity scores to apply a propensity score method and then run an outcome model (return to the section, “Applying the propensity score“). Instead, we can run the outcome model by running an additional macro:

%RunOutcomeModels(ps_cohort , ps); where ps_cohort is the data set that has HDPS, AND defining the outcome model in the %InitHDMacros:
outcome_model_deciles = 1, (to run a decile-based outcome model)
outcome_model_matched = 1, (to run a matched outcome model)

C. Score_type is an indicator for what variables to include in PS estimation/outcome model:

(1) No confounders (unadjusted)
(2) Demographics variables only
(3) Demographics and predefined variables
(4) Demographics, predefined, and empirical (macro-selected) variables
(5) Demographics and empirical (macro-selected) variables

In the example above, score_type_4 = 1 means we are including demographics, predefined, and empirical (macro-selected) variables in PS estimation.

insert_link

For more information, refer to the guide “Using the Pharmacoepi Toolbox in SAS”, which is a downloadable reference available in the toolbox found on this website: https://www.drugepi.org/dope/software#Pharmacoepidemiology