The PSMATCH Procedure
Example 95.6 Mahalanobis Distance Matching
(View the complete code for this example.)
This example performs Mahalanobis distance matching, where the distances between patients in the treatment group and patients in the control group are computed from a set of variables. The data set Drugs contains the patient information and is described in the section Getting Started: PSMATCH Procedure.
The following statements invoke the PSMATCH procedure and request an optimal matching to match patients in the treatment group to patients in the control group, based on Mahalanobis distances:
ods graphics on;
proc psmatch data=drugs region=cs;
class Drug Gender;
psmodel Drug(Treated='Drug_X')= Gender Age Bmi;
match method=optimal(k=1) exact=Gender
stat=mah(lps var=(Age Bmi)) caliper=.25;
assess lps var=(Gender Age Bmi) / weight=none;
output out(obs=match)=OutEx6 matchid=_MatchID;
run;
The CLASS statement specifies the classification variables. The PSMODEL statement specifies the logistic regression model that creates the propensity score for each observation, which is the probability that the patient receives Drug_X. The Drug variable is the binary treatment indicator variable, and TREATED='Drug_X' identifies Drug_X as the treated group. The Gender, Age, and Bmi variables are included in the model because they are believed to be related to the assignment.
The REGION= option specifies an interval region of propensity scores (or equivalently, logits of propensity scores) such that only observations that have propensity scores in the region are used in stratification and matching. Because the MATCH statement is also specified, the REGION=CS option requests that only observations that have propensity scores in the common support region be used for matching. By default, the region is extended by 0.25 times the pooled estimate of the common standard deviation of the logit of the propensity score, where this estimate is the square root of the average of the variances in the treated and control groups.
The MATCH statement specifies the criteria for matching. The STAT=MAH(LPS VAR=(AGE Bmi)) option requests that the Mahalanobis distance, computed from the logit of propensity score and the Age and Bmi variables, be used in computing differences between pairs of observations, The METHOD=OPTIMAL(K=1) option (which is the default) requests optimal matching of one control unit to each unit in the treated group in order to minimize the total within-pair difference. The EXACT=GENDER option forces the treated unit and its matched control unit to have the same value of the Gender variable. The CALIPER=0.25 option specifies the caliper requirement for matching: for a match to be made, the difference in the logits of the propensity score for pairs of individuals from the two groups must be less than or equal to 0.25 times the pooled estimate of the common standard deviation of the logits of the propensity scores.
The "Data Information" table in Output 95.6.1 displays information about the input and output data sets, the numbers of observations in the treated and control groups, the lower and upper limits for the propensity score support region, and the numbers of observations in the treated and control groups that fall within the support region. Of the 373 observations in the control group, 351 fall within the support region.
Output 95.6.1: Data Information
| Data Information | |
|---|---|
| Data Set | WORK.DRUGS |
| Output Data Set | WORK.OUTEX6 |
| Treatment Variable | Drug |
| Treatment Group | Drug_X |
| All Obs (Treatment) | 113 |
| All Obs (Control) | 373 |
| Support Region | Extended Common Support |
| Lower PS Support | 0.050244 |
| Upper PS Support | 0.683999 |
| Support Region Obs (Treatment) | 113 |
| Support Region Obs (Control) | 351 |
The "Propensity Score Information" table in Output 95.6.2 displays summary statistics by treatment group for all observations, for support region observations, and for matched observations.
Output 95.6.2: Propensity Score Information
| Propensity Score Information | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Observations | Treated (Drug = Drug_X) | Control (Drug = Drug_A) | ||||||||
| N | Mean | Std Dev | Minimum | Maximum | N | Mean | Std Dev | Minimum | Maximum | |
| All | 113 | 0.310773 | 0.132467 | 0.060231 | 0.641148 | 373 | 0.208801 | 0.131969 | 0.020157 | 0.685757 |
| Region | 113 | 0.310773 | 0.132467 | 0.060231 | 0.641148 | 351 | 0.217557 | 0.126747 | 0.050951 | 0.682374 |
| Matched | 113 | 0.310773 | 0.132467 | 0.060231 | 0.641148 | 113 | 0.305309 | 0.133560 | 0.064010 | 0.682374 |
The "Matching Information" table in Output 95.6.3 displays the matching criteria, the number of matched sets, the numbers of matched observations in the treated and control groups, and the total Mahalanobis difference for all matches.
Output 95.6.3: Matching Information
The ASSESS statement produces the tables and plots that summarize differences in the specified variables between treated and control groups for all observations, for the support region observations, and for the matched observations. As requested by the LPS and VAR= options, the variables listed in the table are the logit of propensity score and the variables Gender, Age, and Bmi. The WEIGHT=NONE option suppresses display of differences for the weighted matched observations. Note that for a matching of one control unit to each treated unit, the weights are all 1 for matched treated and control units, and the results are identical for the weighted matched observations and the matched observations.
The "Standardized Variable Differences" table, as shown in Output 95.6.4. displays standardized differences between the treated and control groups for all observations, the support region observations, and the matched observations. For a binary classification variable (Gender), the difference is in the proportion of the first ordered level (Female).
Output 95.6.4: Standardized Differences
| Standardized Variable Differences (Treated - Control) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Standardized Mean Difference | |||||||||||
| Mean Difference | Divisor | Mean Difference | Percent Reduction | Variance Ratio | ||||||||
| All Obs | Region Obs | Matched Obs | All Obs | Region Obs | Matched Obs | Region Obs | Matched Obs | All Obs | Region Obs | Matched Obs | ||
| LPS | 0.639971 | 0.545459 | 0.026321 | 0.767448 | 0.833894 | 0.710744 | 0.034297 | 14.77 | 95.89 | 0.6517 | 0.8314 | 0.9899 |
| Age | -4.095091 | -3.493684 | -0.194690 | 6.079104 | -0.673634 | -0.574704 | -0.032026 | 14.69 | 95.25 | 0.7076 | 0.8000 | 1.0214 |
| Bmi | 0.739296 | 0.632566 | 0.018850 | 1.923178 | 0.384414 | 0.328917 | 0.009801 | 14.44 | 97.45 | 0.8854 | 0.9288 | 1.0744 |
| Gender | -0.024817 | -0.016514 | 0 | 0.496925 | -0.049941 | -0.033233 | 0 | 33.46 | 100.00 | 0.9892 | 0.9922 | 1.0000 |
The standardized mean differences are significantly reduced in the matched observations, and the largest of these differences is 0.0343 in absolute value, which is less than the recommended upper limit of 0.25. The variance ratios between the two groups are also in the recommended range of 0.5 to 2. Because both EXACT=GENDER and METHOD=OPTIMAL are specified in the MATCH statement, the standardized difference for Gender is 0 in the matched observations.
When ODS Graphics is enabled, the PSMATCH procedure displays a standardized variable differences plot for the variables that are specified in the ASSESS statement, as shown in Output 95.6.5.
Output 95.6.5: Standardized Differences Plot

The "Standardized Variable Differences Plot" displays the standardized differences in the "Variable Differences" table in Output 95.6.4. All differences for the matched observations are within the recommended limits of –0.25 and 0.25, which are indicated by reference lines.
If you are not satisfied with the variable balance, you can do one or more of the following until you are satisfied: you can select another set of variables to fit the propensity score model, you can modify the matching criteria, or you can choose another matching method.
The OUT(OBS=MATCH)=OutEx6 option in the OUTPUT statement creates an output data set, OutEx6, that contains the matched observations. The following statements list the 10 observations in OutEx6 that have lowest propensity scores, as shown in Output 95.6.6:
proc sort data=OutEx6 out=OutEx6a;
by _ps_;
run;
proc print data=OutEx6a(obs=10);
var PatientID Drug Gender Age Bmi _ps_ _MatchWgt_ _MatchID;
run;
Output 95.6.6: Output Data Set with Mahalanobis Distance Matches
| Obs | PatientID | Drug | Gender | Age | Bmi | _PS_ | _MATCHWGT_ | _MatchID |
|---|---|---|---|---|---|---|---|---|
| 1 | 89 | Drug_X | Female | 44 | 20.75 | 0.06023 | 1 | 1 |
| 2 | 141 | Drug_A | Female | 43 | 20.55 | 0.06401 | 1 | 1 |
| 3 | 323 | Drug_X | Female | 46 | 22.22 | 0.06763 | 1 | 2 |
| 4 | 137 | Drug_A | Female | 45 | 22.04 | 0.07215 | 1 | 2 |
| 5 | 111 | Drug_A | Female | 41 | 21.01 | 0.08714 | 1 | 4 |
| 6 | 217 | Drug_X | Male | 49 | 23.96 | 0.08772 | 1 | 3 |
| 7 | 429 | Drug_A | Male | 49 | 24.00 | 0.08848 | 1 | 3 |
| 8 | 234 | Drug_X | Female | 41 | 21.11 | 0.08904 | 1 | 4 |
| 9 | 183 | Drug_A | Female | 45 | 23.62 | 0.10157 | 1 | 6 |
| 10 | 189 | Drug_A | Female | 46 | 24.10 | 0.10171 | 1 | 5 |
By default, the output data set includes the variable _PS_ (which provides the propensity score) and the variable _MATCHWGT_ (which provides matched observation weights). The weight for each treated unit is 1. Because K=1 is specified in the METHOD= option in the MATCH statement, one control unit is matched to each treated unit; so the weight for each matched control unit is also 1. The MATCHID=_MatchID option creates a variable named _MatchID that identifies the matched sets of observations.
If you assume that no other confounding variables are associated with both the response variable and the treatment group indicator Drug, then after the responses for the trial are observed and added to the data set OutEx6, you can use the same outcome analysis on this output data set as you would have used on the original data set Drugs (augmented with responses) to estimate the treatment effect.
Copyright © SAS Institute Inc. All rights reserved.