*! version 1.0.0 11sep2025 Tzu-Yung Kuo; Adam C. Livori; Lachlan L. Dalli

Title

tenspiders -- Stata command for measuring medication adherence using pharmaceutical claims data. It calculates adherence using the Proportion of Days Covered (PDC) method, with flexible parameters that can be customized according to
the TEN-SPIDERS framework (Dalli et al. Br J Clin Pharmacol. 2022;88(10):4427–4442).

Syntax

tenspiders [using filename] [if] [, options]

dataset

main dataset
using "filename" Specifies the file path to the pharmaceutical claims dataset from which PDC will be calculated. This option cannot be used together with the if qualifier. If using is not specified, a claims dataset
must already be loaded in memory before running the command.

condition
if Optional condition to filter the dataset before calculating PDC. Note: the if qualifier cannot be used together with the using option. See examples below.

Required Varialbes
id(variable) Specifies the variable containing the patient identifier. Must be numeric.

supply_date(date) Specifies the variable containing the dates of medication supply.

Optional Variables

death_date(date) Specifies the variable containing the date of death.
This option is only required if survival is set to 1 or if elig_survival is greater than 0.

event_date(date) Specifies the event date variable (e.g. discharge date). Only required if PDC should be calculated after an event date. numerator_start_date should also be set to 0 to calculate PDC from the event date.
If numerator_start_date is set to 1, PDC is calculated from the first supply date following the event date.

days_supply(variable) Specifies the days supplied variable. Required when dosing is set to 0, and no imputation of days supplied is needed.

drug_id(variable) Specifies the medication classification variable (e.g., ATC code). Required when switching is set to 1 or dosing is set to >0.

drug_strength(variable) Specifies the medication strength variable. Required when dosing is set to >0.

Optional Dataset
hospital_data Specifies the file path to a hospitalisation dataset (in .dta format) containing records of hospital stays during the follow-up period.

The dataset must be in long format, with each row representing a unique hospitalisation, and must include the following variables:

- xadm (admission date)

- xsep (separation/discharge date)

- id (patient identifier matching the id variable used in the main dataset)

This option is only required when inhospital_supply is set to 1 or 2.

TEN-SPIDERS Parameters

threshold Defines the threshold value used to classify patients as adherent (1) or non-adherent (0) based on their PDC.
Default is 0.8.

elig_survival Defines the minimum number of days a patient must survive during the observation period following the numerator start date (either the event date or first supply date, depending on settings).
A value of 0 applies no survival-based exclusion. Greater values indicate the minimum required survival time in days.
Default is 0.

elig_min Defines the minimum number of medication supplies a patient must have during the observation period.
A value of 0 applies no supply-based exclusion. Greater values indicate the minimum required number of supplies.
Default is 0.

numerator_start_date Defines the start date for calculating PDC.
A value of 0 indicates PDC should be calculated from the event date (specified via event_date).
A value of 1 indicates PDC should be calculated from the first supply date.
Default is 1.

denominator_days Defines the follow-up period for measuring PDC following the numerator_start_date, in days.
Default is 365.

survival Defines how survival should be considered in the PDC calculation.
A value of 0 indicates PDC is calculated for the entire follow-up period, regardless of whether death occurs during follow-up.
A value of 1 indicates PDC is calculated only up to the date of death for patients who die during follow-up.
Default is 1.

presupply Defines the look-back window (in days) prior to the event date for identifying pre-supplied medications.
Only medications with remaining supply at the numerator_start_date are considered available during the observation period, and are incorporated within the first supply.
A value of 0 disables the look-back feature.
Default is 0.

inhospital_supply Specifies how hospitalisations during the follow-up period are handled in PDC calculations.
Requires the hospital_data option to specify the file path to the hospitalisation dataset.
A value of 0 indicates no adjustment for hospitalisations.
A value of 1 indicates hospitalised days are assumed to be covered by medication (i.e., included in the numerator).
A value of 2 indicates hospitalised days are excluded from the follow-up period (i.e., excluded from both numerator and denominator).
Default is 0.

dosing Specifies the percentile cut-off for dose imputation.
A value of 0 indicates no imputation is performed, and a days_supply variable must be provided.
A value greater than 0 (from 1 to 100) specifies the percentile used to impute the days_supply variable, based on the time patients typically take to return for a refill of the same medication within the same class.
This requires the following variables: drug_id and drug_strength.
Default is 0.

early_refills Specifies how early refills are handled in PDC calculations.
A value of 0 indicates no adjustment for early refills.
A value of 1 indicates the numerator is extended to account for early refills.
See switching below to apply additional criteria for early refill adjustments.
Default is 1.

switching Specifies how medication switching is considered when adjusting for early refills.
A value of 0 indicates early refill adjustments are applied regardless of medication class.
A value of 1 restricts early refill adjustments to medications within the same class.
This requires the variable drug_id.
Default is 1.

Description

TENSPIDERS Stata command for measuring medication adherence using pharmaceutical claims data.
It calculates adherence using the Proportion of Days Covered (PDC) method, with flexible parameters that can be customized according to the TEN-SPIDERS framework (Dalli et al. Br J Clin Pharmacol. 2022;88(10):4427–4442).
Visit tenspiders.adherencelab.com or our TEN-SPIDERS GitHub page for further information on the TEN-SPIDERS framework and tenspiders Stata command.

Examples

Without adjusting TEN-SPIDERS parameters:

. use "medication.dta", clear

. tenspiders, id(pnn) supply_date(spply_dt) days_supply(qty_sppld) event_date(sep_date) death_date(death_date)

Adjust TEN-SPIDERS parameters:

. use "medication.dta", clear

. tenspiders, id(pnn) supply_date(spply_dt) days_supply(qty_sppld) event_date(sep_date) death_date(death_date) threshold(0.4) switching(0)

When dosing >0:

. use "medication.dta", clear

. tenspiders, id(pnn) supply_date(spply_dt) event_date(sep_date) death_date(death_date) dosing(60) drug_id(atc5_code) drug_strength(itm_cd) inhospital_supply(1)

Include hospital admission data:

. use "medication.dta", clear

. tenspiders, id(pnn) supply_date(spply_dt) days_supply(qty_sppld) event_date(sep_date) death_date(death_date) hospital_data("hosp_data.dta")

Filter drug class for TEN-SPIDERS calculation using if condition:

. use "medication.dta", clear

. tenspiders if class == "Statin", id(pnn) supply_date(spply_dt) days_supply(qty_sppld) event_date(sep_date) death_date(death_date)

Load the main drug dataset using "using" (if is not allowed):

. tenspiders using "medication.dta", id(pnn) supply_date(spply_dt) days_supply(qty_sppld) event_date(sep_date) death_date(death_date)

Stored results

TENSPIDERS saves the following files:

tenspiders_settings.dta Settings of the TEN-SPIDERS package

pdc_outcomes.dta Person-level PDC adherence dataset

Therefore, it is important to set the working directory before running the package using:

cd "c:/directory"

Author

Adam C. Livori*; Tzu-Yung Kuo*; Jedidiah I. Morton; Lachlan L. Dalli

*Joint first authors

Monash University

Email: lachlan.dalli@monash.edu

Website: tenspiders.adherencelab.com

GitHub: github.com/TEN-SPIDERS

References

Dalli, L.L., Kilkenny, M.F., Arnet, I., Sanfilippo, F.M., Cummings, D.M., Kapral, M.K., Kim, J., Cameron, J., Yap, K.Y., Greenland, M., Cadilhac, D.A. (2022).
Towards better reporting of the proportion of days covered method in cardiovascular medication adherence: A scoping review and new tool TEN-SPIDERS.
British Journal of Clinical Pharmacology, 88(10), 4427–4442. doi:10.1111/bcp.15391. PMID: 35524398; PMCID: PMC9546055.

Livori, A.C., Kuo, Tzu-Yung., Ilomäki, J., Kilkenny, M.F., Talic, S., Ademi, Z., Bell, S.J., Morton, J.I., Dalli, L. (2025).
Development of a statistical package to standardise the measurement and reporting of medication adherence using claims data: The TEN-SPIDERS tool.