- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Moved from this old thread: https://communities.sas.com/t5/SAS-Enterprise-Guide/gmatch-macros-don-t-output-data/m-p/417168#M2685...
Hey there! I am trying to use the same macro and am having similar difficulty of having no output data. I am relatively new to SAS and trying to teach myself how to do propensity scoring.
inds =albumin.albumin ,
matchvar = ps,
groupvar = readmission ,
idvar = MRN ,
stratvar = NONE,
caliper = NONE,
caliper_type = ABS,
randseed = -1,
ncntls = 1,
outlinks = _OUTLINKS,
outds = _OUTMATCH,
);
inds =albumin.albumin ,
matchvar = ps,
groupvar = readmission ,
idvar = MRN ,
stratvar = NONE,
caliper = NONE,
caliper_type = ABS,
randseed = -1,
ncntls = 1,
outlinks = _OUTLINKS,
outds = _OUTMATCH,
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS now has the PSMATCH procedure which should be your starting point, if you have SAS 9.4 TS1M5+.
This link has fully worked examples about half way down.
https://support.sas.com/rnd/app/stat/procedures/psmatch.html
PSMATCH Procedure
The PSMATCH procedure provides a variety of tools for performing propensity score analysis. The PSMATCH procedure reduces the effects of confounding in nonrandomized trials or observational studies where the subjects are not randomly assigned to the treatment and control groups.
The PSMATCH procedure computes propensity scores, which estimate the probability that a subject is assigned to treatment given a set of pretreatment (baseline) covariates. The following methods for using the propensity scores to adjust the data for valid estimation of treatment effect are available:
- Inverse probability of treatment weighting and weighting by the odds.
- Stratification of observations that have similar propensity scores. In a subsequent outcome analysis, the treatment effect can be estimated within each stratum, and the estimates can be combined across strata to compute an average treatment effect.
- Matching treated unit with one or more control units that have a similar value of the propensity score.
Methods of matching include:
- fixed ratio matching
- variable ratio matching
- full matching
Provides various plots for assessing balance. Included plots are:
- cloud plots, which are scatter plots in which the points are jittered to prevent overplotting
- box plots for continuous variables
- bar charts for classification variables
- a standardized differences plot that summarizes differences between the treated and control groups
The PSMATCH procedures saves propensity scores and weights in an output data set that contains a sample that has been adjusted either by weighting, stratification, or matching. If the sample is stratified, you can save the strata identification in the output data set. If the sample is matched, you can save the matching identification in the output data set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @ancfletcher and welcome to the SAS Support Communities!
The error message is caused by the comma following "_OUTMATCH" at the end of the macro call. SAS interprets the null value following it as (the value of) a positional parameter, which would need to be specified before the keyword parameters inds, matchvar, etc. But of course, there is no positional parameter defined in this macro. So, as a first step, just delete this comma.
In fact, the comma at the end of the macro definition should be deleted as well because it is unnecessary and (as we've seen) misleading. Another weakness of the macro which I've noticed is that the final PROC DATASETS step is closed with a RUN statement rather than QUIT. I'd recommend to replace that run; by quit; and then rerun the macro definition from %macro ... to %mend; (not only the header %macro gmatch(...);!) before submitting the macro call (%gmatch(...)) again. Please note that by inserting parameter values (such as albumin.albumin) into the macro definition you define these values as default values for the respective parameters. Normally you would leave the macro definition unchanged and supply the parameter values only in the macro call. (Edit: Some default values were defined in the original macro definition, e.g. NONE for parameter stratvar. This means that you could omit "stratvar = NONE," etc. in the macro call, but it doesn't matter if you repeat these parameter assignments again.)
I can't run this macro successfully because it uses PROC IML and I don't have a SAS/IML license. Without delving deeper into propensity score matching I can't help you with your statistical questions about the macro, sorry. Hopefully someone else chimes in.
At least you should now be able to run the macro without syntax errors. Otherwise, please don't hesitate to ask again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS now has the PSMATCH procedure which should be your starting point, if you have SAS 9.4 TS1M5+.
This link has fully worked examples about half way down.
https://support.sas.com/rnd/app/stat/procedures/psmatch.html
PSMATCH Procedure
The PSMATCH procedure provides a variety of tools for performing propensity score analysis. The PSMATCH procedure reduces the effects of confounding in nonrandomized trials or observational studies where the subjects are not randomly assigned to the treatment and control groups.
The PSMATCH procedure computes propensity scores, which estimate the probability that a subject is assigned to treatment given a set of pretreatment (baseline) covariates. The following methods for using the propensity scores to adjust the data for valid estimation of treatment effect are available:
- Inverse probability of treatment weighting and weighting by the odds.
- Stratification of observations that have similar propensity scores. In a subsequent outcome analysis, the treatment effect can be estimated within each stratum, and the estimates can be combined across strata to compute an average treatment effect.
- Matching treated unit with one or more control units that have a similar value of the propensity score.
Methods of matching include:
- fixed ratio matching
- variable ratio matching
- full matching
Provides various plots for assessing balance. Included plots are:
- cloud plots, which are scatter plots in which the points are jittered to prevent overplotting
- box plots for continuous variables
- bar charts for classification variables
- a standardized differences plot that summarizes differences between the treated and control groups
The PSMATCH procedures saves propensity scores and weights in an output data set that contains a sample that has been adjusted either by weighting, stratification, or matching. If the sample is stratified, you can save the strata identification in the output data set. If the sample is matched, you can save the matching identification in the output data set.