Max Rady College of Medicine
Concept: MCHP SAS® Macros
Last Updated: 2021-10-29
Over the last thirty-plus years, programmers at MCHP have developed a series of general use SAS® macros for doing calculations and data processing.
Although developed specifically to run on the data/systems at MCHP, the process involved in some of these macros may be of interest to researchers/data analysts in the health informatics field.
These macros are available free for distribution, development and use under a GNU General Public License (version 3.0).
The names of each macro are listed alphabetically below with a brief description and a link to the SAS code that is available.
For more information on individual macros please contact MCHP.
This macro creates two-by-two tables and the following agreement statistics:
positive predictive value (PPV)
negative predictive value (NPV)
Kappa statistic and p-value
- McNemar's test statistic and p-value
NOTE: see SAS Support on-line documentation titled Usage Note 24170: Sensitivity, specificity, positive and negative predictive values, and other 2x2 table statistics on how to calculate agreement statistics using PROC FREQ at: http://support.sas.com/kb/24/170.html
This is a quick and simple bootstrap program for calculating confidence intervals around mean and median. The jackknife/bootstrap macros from SAS provides more capability and provides the ability to do jackknife analysis as well, it is also more confusing to use.
MCHP SAS Macro Code - ICD-9-CM Charlson Comorbidity Index
MCHP SAS Macro Code - ICD-10 Charlson Comorbidity Index
The Charlson Comorbidity Index (CCI) is a method of categorizing comorbidities based on the International Classification of Disease (ICD) diagnoses and procedure codes of individual patients using administrative data, such as Hospital Discharge Abstracts data. Each comorbidity category has an associated weight, based on the adjusted risk of one-year mortality, and the sum of all the weights results in a single comorbidity score for a patient. A score of zero indicates that no comorbidities were found. The higher the score, the more likely the predicted outcome will result in higher resource use or mortality.
Two different SAS macros are listed above: one for running the Index with ICD-9-CM codes and one for running the Index with ICD-10 codes, depending on the data that is available.
For more information, see the Charlson Comorbidity Index concept.
For more information about comorbidity measures, see the Measures of Comorbidity concept.
Continuity of Care
This macro is used to calculate measures of continuity of care on physician visit data or other sources. The input data is assumed to be only ambulatory care (walkin) visits before processing.
This macro gives a monthly count of the number of admissions, discharges and hospital days over a specified number of months from a specified start date.
This code is specfic for MCHP data and may not be valid in other locations
Dummy Variable Generation
This macro may be used to generate a series of dummy variables (value 1/0) on a data set based on the values of a variable(s). A new variable for each value of the input variables will be generated along with all of the specified interactions. These variables will contain a 1 where value of the input variable and the dummy variable name match, and 0 where they do not.
Dummy variables, sometimes called indicator variables, take values 0 and 1 only. There will be one dummy variable for each level (value) of a categorical variable. As an example, if we have the variable REGION, we could construct 4 dummy variables, named RegN, RegS, RegE, and RegW. The variable RegN would take the value 1 for all observations which had REGION=NORTH, and 0 for all other observations. The variable RegS would take the value 1 for all observations that had REGION=SOUTH and 0 for all other observations, etc. Dummy variables are used in setting up data for logistic regressions.
Episodes of Care and Transfers
This macro will create several new variables on a hospital dataset to mark individual episodes of care. An Episode of care is defined as a continuous stay in the hospital system irrespective of transfers. Transfers should be distinguished not only from readmissions but also from episodes. In all transfer and episode studies you should be aware of episodes that started before the start of the study, and any episodes that start during the study but may continue after the end of the study. Remember that the presence of a second (or third) claim in an episode is less likely to exist the closer you get to the fiscal year end.
For more information see the Episodes of Care concept. This code is specific to MCHP data and may not be valid, or would need modification for other locations.
Existence of SAS dataset
Extract SAS source code from SAS log files
This macro was written for two purposes:
Users that have lost the original source code, but still have the log,for a program that must be re-run.
- Transferring SAS macro code from the log into a runnable program.
The program will read the log file, strip all of the line numbers, NOTES, WARNINGS, SAS headers, ERROR notices from the file. If the file was generated from a macro the resolved macro code will be saved.
- Users that have lost the original source code, but still have the log,for a program that must be re-run.
SAS file size
Determines the approximate size of a SAS file and provides a macro variable.
Creation of Procedure and Diagnosis Code Labels
To create label formats for individual years for ICD-9-CM Procedures or Diagnoses. ICD-9-CM codes are occasionally revised, deleted, added or modified in October by ICD-9-CM. The years in this program reflect the year in which Manitoba Health started to use the new codes. Manitoba Health starts using the new or revised codes at the start of the following fiscal year.
This code was built specific for use at MCHP and relies on a number of supporting databases not available outside of MCHP.
This macro calculates life expectancy tables for regions of Manitoba based on MCHP mortality data.
Computerized Record Linkage
NOTE: This "macro" has been replaced by the LINKS software - see below for more information.
Computerized record linkage refers to the bringing together of data from separate sources which relates to the same individual. Records from two sources are matched in such a way that they may then be treated as a single record for that individual. Records are linked on the basis of common identification data such as surname, given name, date of birth, etc. In many cases, such identifying characteristics may change over time; they may have been recorded incorrectly, or they may be missing in certain records. Thus, the identifying characteristics from the two sources must be compared to estimate the likelihood that a potential link is a "true" one. LinkPro is an integrated SAS application system for probabilistic and deterministic record linkage.
- For more information see the Record Linkage / Data Linkage concept.
LINKS: Computerized Record Linkage
- See LINKS: A Record Linkage Package concept.
Generation of delimited files
Creates a delimited file from any SAS dataset. The output file can be opened by Quattro, Excel, or Lotus, or any other program that reads delimited files. This macro is most useful when using batch SAS.
- Macro - This macro is specific to MCHP data and not useful outside of MCHP.
Print Multiple Graphics/Page
The following is a macro that will print multiple graphs on the same page using the proc greplay command. After generating the graphs that you want, use the macro to produce a page of graphs in N rows by X cols.
Number of observations
Premature mortality rates
Calculates premature mortality rates using MCHP mortality data.
This code is specific to MCHP data and not useful outside of MCHP. See the MCHP Glossary entry on premature mortality rates (PMR)
Potential Years of Life Lost
Calculates potential years of life lost and rates of pyll using MCHP mortality data.
This code is specific to MCHP data and not useful outside of MCHP. See the MCHP Glossary entry on Potential Years of Life Lost (PYLL) .
The POPULIS Rates
Rates of events for various geographical regions, computed by the _rates macro above, are frequently compared in epidemiologic and health services research. The _pop_rate macro computes the crude, the directly standardized, and the indirectly standardized rates for events, ensuring more fair comparisons between different populations. The macro tests if the rates for each area are the same, and which rates differ from the pre-specified rate.
For more information see:
This program is used to attach an income quintile value to a dataset. Income quintiles are attached by postal code in strictly urban areas and by municipality code in mixed urban/rural areas and strictly rural areas. The income quintile ranking is based upon the ranking of the Manitoba population from 1984 to 1997. The years are ranked by census estimates of average household income.
For more information, see
Income Quintiles Based on the 1996 Census
concept. The macro requires a number of datasets and formats built specifically within MCHP and use of the macro outside of MCHP would be complex. The macro has been replaced by a simpler set of SAS formats that are used within MCHP.
- For more current information on how Income Quintile measures are generated, please read the concept Income Quintiles - Child Health Income Quintiles
- For more information, see Income Quintiles Based on the 1996 Census concept. The macro requires a number of datasets and formats built specifically within MCHP and use of the macro outside of MCHP would be complex. The macro has been replaced by a simpler set of SAS formats that are used within MCHP.
This program is used to extract a user defined random sample from a SAS dataset. Several techniques are used to define group or limit the sample.
Read Generic Delimited Files
This macro will read in simple delimited ASCII files. Variables may be named, or labeled based on the delimited values in one of the records. This macro is a very simplistic program, it is not meant to replace the input statements normally used when reading flat files into SAS. This program is a companion to the _lotus macro.
Count Same Procedures (Operations)
This macro will extract all of the claims from the MCHP hospital data that have the same or associated procedures for the same individual within a given number of days. This macro assumes you are using the MCHP hospital discharge abstracts data, and are using the current UNIX format for each of the variables. This macro sorts the input data and removes duplicates. You should restrict your data to the procedures of interest prior to running this macro. This macro should only be used to find and flag places where duplicate and/or associated procedures exist. If the macro is used for counting or checking for overcounts the user should be aware that duplicates may occur for legitimate reasons.
Socio-Economic Risk Index
This macro computes the Socio-Economic Risk Index (SERI) scores by region. By default, SERI scores for the RHAs, treating Winnipeg as a single RHA, are computed. This macro relies on a series of databases available within MCHP.
NOTE: this measure has been replaced by the socioeconomic factor index (SEFI). The MCHP concept dictionary provides information regarding the SEFI in three different concepts: 1). Socioeconomic Factor Index (SEFI) - Based on 1986, 1991, and 1996 Census Data, 2). Socioeconomic Factor Index (SEFI) - Based on the 2001 Census Data, and 3). Socioeconomic Factor Index (SEFI) - Version 2 (SEFI-2).
Nine Winnipeg Regions Definition
This macro is used to generate a new variable that contains 9 Winnipeg sub-regions. The subregions are based on 1986 Census Family income by Postal Code (by Cam Mustard & Ruth). This code groups Winnipeg into geographical areas with similar family income distribution, while also observing boundaries which exist between the City of Winnipeg Health Dept. and Manitoba Health. The areas Inner Core, Outer Core and South Central correspond to the City's Health Dept's service area while the remaining sub-regions correspond to ADMINISTRATIVE "areas" established by the Provincial Health Dept. for Winnipeg. A new variable may be added to a data set, or an existing regional variable may be adjusted to include the 9 regions. With the creation of the Manitoba Regional Health Authorities and other policy related Winnipeg regions this code is no longer being used.
- Charlson Comorbidity Index
- Confidence Interval of Median
- Episodes of Care
- Income Quintiles Based on the 1996 Census
- LINKS: A Record Linkage Package
- Measuring Continuity of Care (Continuity of Care Index)
- Measuring Majority of Care
- Physician / Hospital Claims
- Rates of Utilization
- Record Linkage / Data Linakge
- Socioeconomic Factor Index (SEFI) - Based on the 1986, 1991, and 1996 Census Data
- Statistics for Large Databases
- Potential Years of Life Lost (PYLL)
- Premature Mortality Rate (PMR)
- Statistical Analysis System / Statistical Analysis Software (SAS®)
Manitoba Centre for Health Policy
Community Health Sciences, Max Rady College of Medicine,
Rady Faculty of Health Sciences,
Room 408-727 McDermot Ave.
University of Manitoba
Winnipeg, MB R3E 3P5 Canada