Skip to main content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it's official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you're on a federal government site.


The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Toolkit: Using Data Analysis To Calculate Opioid Levels and Identify Patients At Risk of Misuse or Overdose

SAS® Programming Code

This SAS programming code is a part of this Toolkit to assist users in analyzing large datasets of prescription drug claims to identify individuals at risk of potential opioid abuse or misuse.
Download the
SAS Icon SAS programming code
[SAS - 18 KB]

Related Information

Combatting the Opioid Crisis: Priority Area


This toolkit provides detailed steps for using prescription drug claims data to analyze patients' opioid levels and identify certain patients who are at risk of opioid misuse or overdose. It is based on the methodology that OIG has developed in our extensive work on opioids.

This new OIG product provides highly technical information to support our public and private sector partners, such as Medicare Part D plan sponsors, private health plans, and State Medicaid Fraud Control Units. It is intended to assist our partners with analyzing their own prescription drug claims data to help combat the opioid crisis.


Opioid abuse and overdose deaths are at epidemic levels in the United States. As one of the lead Federal agencies fighting health care fraud, OIG is committed to supporting our public and private partners in their efforts to curb the opioid epidemic. These partners include Medicare Part D plan sponsors, other private health plans, State Medicaid Fraud Control Units, State prescription drug monitoring programs, and researchers. They can use this toolkit to analyze claims data for prescription drugs and identify patients who may be misusing or abusing prescription opioids and may be in need of additional case management or other followup. This toolkit can also be used to answer research questions about opioid utilization.

OIG most recently analyzed opioid levels in the data brief Opioid Use in Medicare Part D Remains Concerning (OEI-02-18-00220), which is being released alongside this toolkit. The data brief identified about 71,000 Part D beneficiaries who were at serious risk of misuse or overdose. Some of these beneficiaries received extreme amounts of opioids. Others appeared to be "doctor shopping," i.e., receiving high amounts of opioids from multiple prescribers and multiple pharmacies. The analysis identified beneficiaries who are at risk by calculating their opioid levels using Part D prescription drug data.


This toolkit provides steps to calculate patients' average daily morphine equivalent dose (MED), which converts various prescription opioids and strengths into one standard value. This measure is also called morphine milligram equivalent (MME). The toolkit includes a detailed description of the analysis and programming code that can be applied to the user's own data. The resulting data can be used to identify certain patients who are at risk of opioid misuse or overdose. Users can also modify the code to meet their needs, such as identifying patients at other levels of risk. The toolkit has three chapters: (1) Analysis of Prescription Drug Claims Data, (2) Explanation of the Programming Code To Conduct the Analysis, and (3) Programming Code.