I am a SAS programmer, and have built an opioid morphine milligram equivalent (MME) calculator using Base/SAS. Deploying any kind of SAS distributable is difficult because the end-user would have to have a SAS license, which is very expensive. I do have the option of SAS/Connect, which is a client/server setting, but I want my end-users to keep their data on their systems, and not upload to a SAS server in the cloud. The reason is, the data privacy is very important with medical claims. So. The code is not terribly complicated, but I don't know where to start to convert it to a self-contained executable with a user interface so that the end-user can browse a file on their system, then run the program to calculate the MME per patient. The deliverable back to the end user would be summary file(s) of the patient's daily opioid MME dose, and other reports the end-user may want. I can do all of this in SAS but SAS does not make it is to distribute code. Maybe if I share the code and explain what it does, someone could help me? It would be a paying job $$.
Here is the SAS code using Hash Tables.
The second method of calculating a patient’s daily opioid MME dose involves SAS Hash Tables. I have relied on several SAS papers describing how to use hash tables, please see the references section at the end of this article. Assume dataset CLAIMS has the following columns: PATIENT_ID, RX_FILL_DATE, NDC_CODE, DAYS_SUPPLY, QTY_DISPENSED, DAILY_MME_DOSE, STRENGTH_PER_UNIT, MME_CF (MME conversion factor), and that the DAILY_MME_DOSE column has already been calculated using the formula below: DAILY_MME_DOSE = STRENGTH_PER_UNIT*(QTY_DISPENSED/DAYS_SUPPLY)*MME_CF
Create a DATA _NULL_ step, which will loop through the dataset CLAIMS, and add the patient’s daily MME doses across multiple opioid prescriptions and multiple prescribers, if there are any.
DATA _NULL_;
FORMAT DATE DATE9.;
/* define the hash table PATIENT_MMES, it starts out empty */
DECLARE HASH PATIENT_MMES();
/* define the two-part key for the hash table: PATIENT_ID and DATE */
RC=PATIENT_MMES.DEFINEKEY('PATIENT_ID','DATE');
/* define the data to be included in the PATIENT_MMES hash table, adding the TOTAL_MMES column, which we will be adding to as we iterate through the dataset CLAIMS */
RC=PATIENT_MMES.DEFINEDATA('PATIENT_ID','DATE','TOTAL_MMES');
RC=PATIENT_MMES.DEFINEDONE();
/* iterate through the CLAIMS dataset until the end-of-file (EOF) is reached */
DO UNTIL (EOF);
SET CLAIMS END=EOF;
/* initialize TOTAL_MMES to missing */
TOTAL_MMES = .;
/* iterate through the entire days supply of each opioid script: */
DO I = 0 TO (DAYS_SUPPLY-1);
/* define DATE as a dynamic date counter, it will loop through every day in the drug’s days supply */
DATE = RX_FILL_DATE + I;
/* define DAY as the day number of the DAYS_SUPPLY */
DAY = I+1;
/* initialize TOTAL_MMES to the first DAILY_MME_DOSE */
TOTAL_MMES = DAILY_MME_DOSE;
/* use the Find function to look up the patient_id and the date. If the combination is not found, then add the patient_id, date, and TOTAL_MMES to the hash table PATIENT_MMES */
RC=PATIENT_MMES.FIND();
/* RC is 0 if the patient_id, date combination was found
RC is not 0 if the patient_id, date combination was not found
If not found, then add to the hash table */
IF RC NE 0 THEN PATIENT_MMES.ADD();
/* If the patient-date combination is found, because we already
added it, then increment the TOTAL_MMES by the DAILY_MME_DOSE */
IF RC=0 THEN
DO;
TOTAL_MMES = TOTAL_MMES + DAILY_MME_DOSE;
/* if the combination was found, then replace the
TOTAL_MMES with its new, incremented value */
RC=PATIENT_MMES.REPLACE();
END;
END;
/* when the end-of-file is reached, output to the dataset
PATIENT_DATE_SUMMARY */
IF EOF THEN PATIENT_MMES.OUTPUT(dataset: 'PATIENT_DATE_SUMMARY’);
STOP;
RUN;