The PSMATCH Procedure
Example 95.4 Greedy Nearest Neighbor Matching
(View the complete code for this example.)
This example performs greedy matching in a propensity score analysis.
At the completion of a school year, a school administrator asks whether taking a music class causes an improvement in the grade point averages (GPAs) of students. The reasoning behind this question is that learning to read and perform music might improve general reading ability, concentration, and memory.
The data set School contains information about students that is available at the end of the school year. StudentID is the student identification number, Music indicates whether the student took a music class, Gender provides the gender of the student, and Absence is the percentage of absences. For simplicity, this example uses only three covariates (Music, Gender, and Absence), but in practice a propensity score analysis often involves many more covariates.
Output 95.4.1 lists the first 10 observations.
Output 95.4.1: Input School Data Set
In this example, the outcome data (GPAs) for the students happen to be available at the time of the propensity score analysis, but the recommended practice is not to use the outcome values in the propensity score analysis (Stuart 2010, p. 2). Instead, the response variable is added to the output data set created by the PSMATCH procedure; that output data set consists of matched observations that are subsequently used in an outcome analysis.
The following statements invoke the PSMATCH procedure and request greedy nearest neighbor matching to sequentially match each observation for students in the treatment group (those who took music) with one observation for students in the control group (those who did not take music):
ods graphics on; proc psmatch data=School region=treated; class Music Gender; psmodel Music(Treated='Yes')= Gender Absence; match method=greedy(k=1) exact=Gender caliper=0.5; assess lps var=(Gender Absence) / plots=all weight=none; output out(obs=match)=OutEx4 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 student, which is the probability that the student enrolled in the music class. The Music variable is the binary treatment indicator variable and TREATED='Yes' identifies Yes as the treated group. The Gender and Absence variables are included in the model because they are believed to be related to enrolling in the music class.
The REGION= option specifies an interval region 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=TREATED option requests that only observations whose propensity scores lie in the range that corresponds to observations in the treated group 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 statistic.
The MATCH statement requests matching and specifies the criteria for matching. The STAT=LPS option (which is the default) requests that the logit of the propensity score be used in computing differences between pairs of observations. The METHOD=GREEDY(K=1) option requests greedy nearest neighbor matching in which one control unit is matched with each unit in the treated group such that the matching produces the smallest within-pair difference among all available pairs with this treated unit. 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.5 option specifies the caliper requirement for matching: units are matched only if the difference in the logits of the propensity score for pairs of units from the two groups is less than or equal to 0.5 times the pooled estimate of the common standard deviation of the logits of the propensity scores.
The "Data Information" table, which is produced by the PSMATCH procedure and shown in Output 95.4.2, 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 140 observations in the control group, 132 fall within the support region.
Output 95.4.2: Data Information
| Data Information | |
|---|---|
| Data Set | WORK.SCHOOL |
| Output Data Set | WORK.OUTEX4 |
| Treatment Variable | Music |
| Treatment Group | Yes |
| All Obs (Treatment) | 60 |
| All Obs (Control) | 140 |
| Support Region | Extended Treatment Group |
| Lower PS Support | 0.079975 |
| Upper PS Support | 0.530932 |
| Support Region Obs (Treatment) | 60 |
| Support Region Obs (Control) | 132 |
The "Propensity Score Information" table in Output 95.4.3 displays summary statistics for the treatment and control groups, which are computed for all observations, support region observations, and matched observations.
Output 95.4.3: Propensity Score Information
| Propensity Score Information | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Observations | Treated (Music = Yes) | Control (Music = No) | ||||||||
| N | Mean | Std Dev | Minimum | Maximum | N | Mean | Std Dev | Minimum | Maximum | |
| All | 60 | 0.347143 | 0.096184 | 0.092831 | 0.490191 | 140 | 0.279796 | 0.124997 | 0.026465 | 0.488875 |
| Region | 60 | 0.347143 | 0.096184 | 0.092831 | 0.490191 | 132 | 0.294024 | 0.113997 | 0.083346 | 0.488875 |
| Matched | 60 | 0.347143 | 0.096184 | 0.092831 | 0.490191 | 60 | 0.340188 | 0.098482 | 0.092963 | 0.488875 |
The "Matching Information" table in Output 95.4.4 displays the matching criteria, the number of matched sets, the numbers of matched observations in the treated and control groups, and the total absolute difference in the logit of the propensity score for all matches.
Output 95.4.4: Matching Information
The ASSESS statement produces 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. You can use these results to assess how well matching achieves a balance in the distributions of these variables. As requested by the LPS and VAR= options, the variables are the logit of propensity score and the covariates Gender and Absence. The WEIGHT=NONE option suppresses the display of differences for weighted matched observations. 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 in Output 95.4.5 displays standardized differences between the treated and control groups, which are computed for all observations, support region observations, and matched observations. For the binary classification variable (Gender), the computed difference is in the proportion of the first ordered level (Female).
Output 95.4.5: 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.406809 | 0.284163 | 0.032679 | 0.652514 | 0.623449 | 0.435489 | 0.050081 | 30.15 | 91.97 | 0.3810 | 0.6135 | 0.9696 |
| Absence | -0.697568 | -0.485721 | -0.057759 | 1.136945 | -0.613546 | -0.427216 | -0.050802 | 30.37 | 91.72 | 0.3550 | 0.5560 | 0.9375 |
| Gender | -0.045238 | -0.034848 | 0 | 0.496344 | -0.091143 | -0.070210 | 0 | 22.97 | 100.00 | 1.0208 | 1.0144 | 1.0000 |
The standardized mean differences are significantly reduced in the matched observations, and the largest of these differences is 0.0508 in absolute value, which is less than the recommended upper limit of 0.25 (Rubin 2001, p. 174; Stuart 2010, p. 11). The variance ratios between the two groups are between 0.9375 1 and 1 for all variables in the matched observations, which is within the recommended range of 0.5 to 2. Because both EXACT=GENDER and METHOD=GREEDY are specified in the MATCH statement, the standardized difference for Gender is 0 in the matched observations.
When ODS Graphics is enabled and you specify PLOTS=ALL, the PSMATCH procedure uses ODS Graphics to create all applicable plots. Output 95.4.6 displays a plot of the standardized differences in Gender, Absence, and the logit propensity score for all observations, observations in the support region, and matched observations.
Output 95.4.6: Standardized Differences Plot

Output 95.4.7 displays box plots that compare the distributions of the logit propensity score for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Note that the two distributions are well-balanced for matched observations.
Output 95.4.7: LPS Box Plot

Output 95.4.8 displays box plots that compare the distributions of Absence for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Again, note that the two distributions are well-balanced for matched observations.
Output 95.4.8: Absence Box Plot

Output 95.4.9 displays bar charts that compare the distributions of Gender for units in the treated and control groups, based on all observations, observations in the support region, and matched observations. Again, note that the two distributions are well-balanced for matched observations.
Output 95.4.9: Gender Bar Chart

Output 95.4.10 displays a cloud plot that compares the values of the logit propensity score LPS for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations. The points are jittered in the vertical direction to avoid overlap.
Output 95.4.10: LPS Cloud Plot

Output 95.4.11 displays a cloud plot that compares the values of Absence for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations.
Output 95.4.11: Absence Cloud Plot

Output 95.4.12 displays a cloud plot that compares the values of Gender for observations in the treated and control groups, based on all observations, observations in the support region, and matched observations.
Output 95.4.12: Gender Cloud Plot

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)=OutEx4 option in the OUTPUT statement creates an output data set, OutEx4, that contains the matched observations. The following statements list the 10 observations in OutEx4 that have lowest propensity scores, as shown in Output 95.4.13:
proc sort data=OutEx4 out=OutEx4a; by _PS_; run; proc print data=OutEx4a(obs=10); var StudentID Music Gender Absence _PS_ _MATCHWGT_ _MatchID; run;
Output 95.4.13: Output Data Set with Multiple Matches
| Obs | StudentID | Music | Gender | Absence | _PS_ | _MATCHWGT_ | _MatchID |
|---|---|---|---|---|---|---|---|
| 1 | 33 | Yes | Female | 3.50313 | 0.09283 | 1 | 60 |
| 2 | 82 | No | Female | 3.50036 | 0.09296 | 1 | 60 |
| 3 | 67 | Yes | Female | 2.71352 | 0.13790 | 1 | 59 |
| 4 | 95 | No | Female | 2.53865 | 0.15009 | 1 | 59 |
| 5 | 47 | No | Female | 2.49866 | 0.15300 | 1 | 58 |
| 6 | 4 | Yes | Female | 2.49425 | 0.15333 | 1 | 58 |
| 7 | 37 | No | Male | 2.93955 | 0.15549 | 1 | 57 |
| 8 | 152 | Yes | Male | 2.88102 | 0.15988 | 1 | 57 |
| 9 | 20 | Yes | Female | 2.12751 | 0.18224 | 1 | 56 |
| 10 | 121 | No | Female | 2.12239 | 0.18267 | 1 | 56 |
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 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 GPA and the music class indicator Music, you can add the GPAs for the students to the data set OutEx4 and perform an outcome analysis of GPA on this data set to estimate the music class effect.
Copyright © SAS Institute Inc. All rights reserved.