Comorbidity SAS Macro (2000 version)

The below macros are provided to assist investigators with their analysis. NCI does not accept responsibility for the completeness or accuracy of the codes and weights used in the macros. Investigators may modify the macros if they wish to include different diagnosis codes or condition weights.

The first decision that an investigator must make is whether to use claims only from the hospital file (MEDPAR) or to also include the diagnoses on claims submitted by physicians (NCH) and outpatient facilities (OUTPAT), as described in Klabunde et al. The rationale for including the latter claims is that many more people see a physician or receive care in an outpatient clinic than are hospitalized, thus increasing the possibility of identifying more comorbid conditions. If researchers only want to use MEDPAR data, then there is no need to use the rule-out SAS macro. If, however, researchers want to also use the physician and outpatient files, then they will need to first run the rule-out macro.

  1. remove.ruleout.dxcodes.macro.v2000.txt
    This macro is only needed if both physician/outpatient and hospital claims are being used to identify comorbid conditions. This macro requires that for physician and outpatient claims, a patient's diagnoses must appear on at least two different claims that are more than 30 days apart. The reason for this is that the diagnoses on the physician and outpatient claims have not been validated and it is possible that physicians may have recorded a diagnosis as being present, when the correct coding would be "rule-out" the condition. Conditions that do not appear on two different claims are considered to be "rule-out" diagnoses, and are not counted as comorbid conditions. This is necessary to prevent over-estimation of the comorbidity when using physician or outpatient claims.
  2. charlson.comorbidity.macro.v2000.txt
    This macro calculates Charlson comorbidity weights from the claims and was developed in 2000. The SAS macro considers the ICD-9 diagnosis codes, ICD-9 procedure codes, and HCPCS procedure codes on the claims. Researchers using hospital data with physician or outpatient data need to use the file produced from the first macro.

Building an Input File for the Macros

Regardless of which files an investigator decides to use, the files should be subset to include a limited number of variables as described below. All ICD-9-CM diagnosis codes on these records should be 5 characters long and ICD-9-CM procedure codes should be 4 characters long. Before invoking the SAS macros, decimal points or blanks occurring within the number should be removed from the code (ex. diagnosis code '123.4' becomes '1234 ').

Variables to retain for the macros:

  • MEDPAR data - retain Patient_ID (or REGCASE), admission date, diagnosis codes 1-25 surgery codes 1-25 and length of stay. Set filetype=M.
  • Carrier data - retain Patient_ID (REGCASE), claim from date, HCPCS, diagnosis codes 1-13 (twelve of the diagnoses are from the header of the claim and one is the line item diagnosis). The carrier data can have more than one claim for the same date of service and all claims for each date should be included. Set filetype=N.
  • Outpatient data - retain Patient_ID (or REGCASE), claim from date, HCPCS, diagnosis codes 1-25, ICD procedure codes 1-13. Set filetype=O.

The final SAS file which combines data from any of the above sources must include the variables used in the Macro call. For each record a flag (IDXPRI) needs to be created to flag records that fall within the window of analysis. For example, if the comorbidity score for the 12 months prior to diagnosis is to be calculated, then records with claim dates falling within that window should have IDXPRI set to "P". If however the window is to be the month of diagnosis, then records with the claim date within the month of diagnosis should have IDXPRI set to "I". Records not in the analysis window should have IDXPRI left blank, or should be excluded from the final SAS file.

These variables are needed for the Comorbidity macro:

PATID - Patient ID

IDXPRI - Event Window indicator, "P"=Prior, "I"=Index

DAYS - Length of stay for Hospital visits, only for MEDPAR records

DXVARSTR - Diagnosis array, such as DX1-DX25. Note: DX14-DX25 are blank for NCH/carrier data

NDXVAR - Number of variables in Diagnosis array, maximum 25

SXVARSTR - Procedure array, such as surgery codes from MEDPAR and procedure codes from Outpatient. Note: These are blank for NCH/carrier data

NSXVAR - Number of variables in Procedure array, maximum 25

HCPCS - Outpatient and NCH/Carrier procedure codes in CPT-4. Note: This is blank for MEDPAR records

FILETYPE - M-MEDPAR, N-NCH/Carrier, O-Outpatient

These variables are needed for the rule-out macro:

PATID - Patient ID

CLMDTE - Admission date from Medpar, claim from date from NCH/carrier and Outpatient (in SAS date format)

START - Start of comorbidity window, such as 12 months prior to Diagnosis Date (in SAS date format)

FINISH - End of comorbidity window, such as 1 month prior to Diagnosis Date (in SAS date format)