The PSMATCH Procedure
Example 95.5 Matching with Replacement
(View the complete code for this example.)
This example performs matching with replacement in the propensity score analysis. The data set School contains the student information and is described in Example 95.4.
The following statements invoke the PSMATCH procedure and request matching with replacement to match observations for students in the treatment group with observations for students in the control group:
ods graphics on; proc psmatch data=School region=allobs(psmin=0.05); class Music Gender; psmodel Music(Treated='Yes')= Gender Absence; match method=replace(k=1) stat=ps exact=Gender caliper=.; assess ps var=(Gender Absence); output out(obs=match)=outex5 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=ALLOBS(PSMIN=0.05) option requests that all available observations whose propensity scores are greater than or equal to 0.05 be used for matching.
The MATCH statement requests matching and specifies the criteria for matching. The STAT=PS option requests that the propensity score be used in computing differences between pairs of observations. The METHOD=REPLACE(K=1) option requests matching with replacement in which each treated unit is matched to the closest control 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=. option ignores the caliper requirement for matching.
The "Data Information" table in Output 95.5.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 140 observations in the control group, 134 fall within the support region.
Output 95.5.1: Data Information
| Data Information | |
|---|---|
| Data Set | WORK.SCHOOL |
| Output Data Set | WORK.OUTEX5 |
| Treatment Variable | Music |
| Treatment Group | Yes |
| All Obs (Treatment) | 60 |
| All Obs (Control) | 140 |
| Support Region | PS Bounded Obs |
| Lower PS Support | 0.05 |
| Upper PS Support | 0.490191 |
| Support Region Obs (Treatment) | 60 |
| Support Region Obs (Control) | 134 |
The "Propensity Score Information" table in Output 95.5.2 displays summary statistics by treatment group for all observations, for support region observations, and for matched observations.
Output 95.5.2: 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 | 134 | 0.290611 | 0.116521 | 0.051746 | 0.488875 |
| Matched | 60 | 0.347143 | 0.096184 | 0.092831 | 0.490191 | 41 | 0.335146 | 0.103487 | 0.092963 | 0.488875 |
Note that the number of matched control units (41) is less than the number of matched treated units (60) because for matching with replacement, a control unit can be matched with more than one treated unit.
The "Matching Information" table in Output 95.5.3 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 propensity score for all matches. For matching with replacement, one control unit might be matched to more than one treated unit. In this example, 41 control units are matched to 60 treated units.
Output 95.5.3: 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 the matching achieves a balance in the distributions of these variables. As requested by the PS and VAR= options, the variables are the propensity score and the covariates Gender and Absence.
The "Standardized Variable Differences" table displays standardized differences between the treated and control groups for all observations, the support region observations, and the matched observations, as shown in Output 95.5.4.
Output 95.5.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 | Weighted Matched Obs | All Obs | Region Obs | Matched Obs | Weighted Matched Obs | Region Obs | Matched Obs | Weighted Matched Obs | All Obs | Region Obs | Matched Obs | Weighted Matched Obs | ||
| PS | 0.067347 | 0.056532 | 0.011997 | 0.001176 | 0.111525 | 0.603876 | 0.506900 | 0.107574 | 0.010546 | 16.06 | 82.19 | 98.25 | 0.5921 | 0.6814 | 0.8638 | 1.0062 |
| Absence | -0.697568 | -0.531749 | -0.087541 | -0.008541 | 1.136945 | -0.613546 | -0.467700 | -0.076997 | -0.007513 | 23.77 | 87.45 | 98.78 | 0.3550 | 0.5050 | 0.8192 | 1.0029 |
| Gender | -0.045238 | -0.033831 | -0.052033 | 0 | 0.496344 | -0.091143 | -0.068160 | -0.104831 | 0 | 25.22 | 0.00 | 100.00 | 1.0208 | 1.0138 | 1.0254 | 1.0000 |
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.5.5.
Output 95.5.5: Standardized Differences Plot

The "Standardized Variable Differences Plot" displays the standardized differences in the "Variable Differences" table in Output 95.5.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)=OutEx5 option in the OUTPUT statement creates an output data set, OutEx5, that contains the matched observations. The following statements list the 10 observations in OutEx5 that have the largest propensity scores, as shown in Output 95.5.6.
proc sort data=OutEx5 out=OutEx5a; by descending _PS_; run; proc print data=OutEx5a(obs=10); var StudentID Music Gender Absence _PS_ _MATCHWGT_ _MatchID; run;
Output 95.5.6: Output Data Set of Matched Observations with Replacement
| Obs | StudentID | Music | Gender | Absence | _PS_ | _MATCHWGT_ | _MatchID |
|---|---|---|---|---|---|---|---|
| 1 | 156 | Yes | Male | 0.01792 | 0.49019 | 1 | 41 |
| 2 | 142 | Yes | Male | 0.02451 | 0.48926 | 1 | 41 |
| 3 | 105 | No | Male | 0.02723 | 0.48888 | 2 | 41 |
| 4 | 64 | No | Male | 0.03317 | 0.48804 | 1 | 40 |
| 5 | 98 | Yes | Male | 0.05443 | 0.48503 | 1 | 40 |
| 6 | 30 | No | Male | 0.10043 | 0.47853 | 2 | 39 |
| 7 | 182 | Yes | Male | 0.10352 | 0.47810 | 1 | 39 |
| 8 | 115 | Yes | Male | 0.11002 | 0.47718 | 1 | 39 |
| 9 | 130 | No | Male | 0.17651 | 0.46780 | 1 | 38 |
| 10 | 104 | Yes | Male | 0.18986 | 0.46592 | 1 | 38 |
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 OutEx5 and perform an outcome analysis of GPA on this data set to estimate the music class effect.
Copyright © SAS Institute Inc. All rights reserved.