<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help with macros! Trouble using Propensity Score matching in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556220#M154942</link>
    <description>&lt;P&gt;SAS now has the PSMATCH procedure which should be your starting point, if you have SAS 9.4 TS1M5+.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This link has fully worked examples about half way down.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/app/stat/procedures/psmatch.html" target="_blank"&gt;https://support.sas.com/rnd/app/stat/procedures/psmatch.html&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H2&gt;PSMATCH Procedure&lt;/H2&gt;
&lt;HR /&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Inverse probability of treatment weighting and weighting by the odds.&lt;/LI&gt;
&lt;LI&gt;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.&lt;/LI&gt;
&lt;LI&gt;Matching treated unit with one or more control units that have a similar value of the propensity score.&lt;/LI&gt;
Methods of matching include:
&lt;UL&gt;
&lt;LI&gt;fixed ratio matching&lt;/LI&gt;
&lt;LI&gt;variable ratio matching&lt;/LI&gt;
&lt;LI&gt;full matching&lt;/LI&gt;
&lt;/UL&gt;
&lt;/UL&gt;
&lt;P&gt;Provides various plots for assessing balance. Included plots are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;cloud plots, which are scatter plots in which the points are jittered to prevent overplotting&lt;/LI&gt;
&lt;LI&gt;box plots for continuous variables&lt;/LI&gt;
&lt;LI&gt;bar charts for classification variables&lt;/LI&gt;
&lt;LI&gt;a standardized differences plot that summarizes differences between the treated and control groups&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Sat, 04 May 2019 21:10:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-05-04T21:10:12Z</dc:date>
    <item>
      <title>Help with macros! Trouble using Propensity Score matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556204#M154932</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Moved from this old thread:&amp;nbsp;&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/gmatch-macros-don-t-output-data/m-p/417168#M26853" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/gmatch-macros-don-t-output-data/m-p/417168#M26853&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;FONT face="Arial"&gt;I am using the&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Paper 689-2017 "&lt;/SPAN&gt;A Practical Guide to Getting Started with Propensity Scores" which has&amp;nbsp;been extremely helpful.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT face="Arial"&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings17/0689-2017.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/resources/papers/proceedings17/0689-2017.pdf&lt;/A&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT face="Arial"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT face="Arial"&gt;I successfully created a propensity score variable (ps) via:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT face="Arial"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;proc logistic data=albumin.albumin;&lt;/DIV&gt;&lt;DIV class=""&gt;class gender smoking diabetes ;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;model readmission = albuminpre gender BMI age smoking diabetes/&lt;/DIV&gt;&lt;DIV class=""&gt;link=glogit rsquare;&lt;/DIV&gt;&lt;DIV class=""&gt;output out = ps_los pred = ps xbeta=logit_ps;&lt;/DIV&gt;&lt;DIV class=""&gt;run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;But have been unsuccessfully able to use the macro. I have tried both the Duke and Mayo version macros:&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A href="http://people.duke.edu/~hammill/software/gmatch.sas" target="_blank" rel="noopener"&gt;http://people.duke.edu/~hammill/software/gmatch.sas&lt;/A&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A href="https://github.com/Jiangtang/Programming-SAS/blob/master/UserMacros/mayo/gmatch.sas" target="_blank" rel="noopener"&gt;https://github.com/Jiangtang/Programming-SAS/blob/master/UserMacros/mayo/gmatch.sas&lt;/A&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I am using the Duke code:&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;%macro gmatch(&lt;BR /&gt;inds =albumin.albumin ,&lt;BR /&gt;matchvar = ps,&lt;BR /&gt;groupvar = readmission ,&lt;BR /&gt;idvar = MRN ,&lt;BR /&gt;stratvar = NONE,&lt;BR /&gt;caliper = NONE,&lt;BR /&gt;caliper_type = ABS,&lt;BR /&gt;randseed = -1,&lt;BR /&gt;ncntls = 1,&lt;BR /&gt;outlinks = _OUTLINKS,&lt;BR /&gt;outds = _OUTMATCH,&lt;BR /&gt;);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;It runs quickly and without error. It is my understanding that this is defining my macro? Then if I try to call on the macro (as&amp;nbsp; below), nothing happens or I get the error&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;%gmatch(&lt;BR /&gt;inds =albumin.albumin ,&lt;BR /&gt;matchvar = ps,&lt;BR /&gt;groupvar = readmission ,&lt;BR /&gt;idvar = MRN ,&lt;BR /&gt;stratvar = NONE,&lt;BR /&gt;caliper = NONE,&lt;BR /&gt;caliper_type = ABS,&lt;BR /&gt;randseed = -1,&lt;BR /&gt;ncntls = 1,&lt;BR /&gt;outlinks = _OUTLINKS,&lt;BR /&gt;outds = _OUTMATCH,&lt;BR /&gt;);&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 %gmatch(&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 inds =albumin.albumin ,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 matchvar = ps,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 groupvar = readmission ,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 idvar = MRN ,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 stratvar = NONE,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 caliper = NONE,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80 caliper_type = ABS,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81 randseed = -1,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;82 ncntls = 1,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;83 outlinks = _OUTLINKS,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;84 outds = _OUTMATCH,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;85 );&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;86&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;87&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;88 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;100&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I honestly don't even know if I am inputing my variables correctly....I would imagine I use my created propensity score “ps” variable for the mvars, but am unsure what to use for the group (?readmission) and ID (something unique to each record- patient, &amp;nbsp;MRN?).&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;The question I am trying to answer is if albumin is still a significant predictor for hospital readmission when controlling for other covariates. ( I have a lot of independent variables, but just keeping it simple with a few for now).&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thank you for your time and consideration. I appreciate any guidance.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 20:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556204#M154932</guid>
      <dc:creator>ancfletcher</dc:creator>
      <dc:date>2019-05-04T20:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using Propensity Score matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556216#M154939</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272880"&gt;@ancfletcher&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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 &lt;FONT face="courier new,courier"&gt;inds&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;matchvar&lt;/FONT&gt;, etc. But of course, there is no positional parameter defined in this macro. So, as a first step, just delete this comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, the comma at the end of the macro &lt;EM&gt;definition&lt;/EM&gt; 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&amp;nbsp;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt; by &lt;FONT face="courier new,courier"&gt;quit;&lt;/FONT&gt; and then rerun the macro definition from &lt;FONT face="courier new,courier"&gt;%macro&lt;/FONT&gt; ... to&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%mend;&lt;/FONT&gt; (not only the header &lt;FONT face="courier new,courier"&gt;%macro gmatch(...);&lt;/FONT&gt;!) before submitting the macro call (&lt;FONT face="courier new,courier"&gt;%gmatch(...)&lt;/FONT&gt;) again. Please note that by inserting parameter values (such as &lt;FONT face="courier new,courier"&gt;albumin.albumin&lt;/FONT&gt;) into the macro definition you define these values as &lt;EM&gt;default&lt;/EM&gt; 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. &lt;FONT face="courier new,courier"&gt;NONE&lt;/FONT&gt; for parameter &lt;FONT face="courier new,courier"&gt;stratvar&lt;/FONT&gt;. This means that you could omit "&lt;FONT face="courier new,courier"&gt;stratvar = NONE,&lt;/FONT&gt;" etc. in the macro call, but it doesn't matter if you repeat these parameter assignments again.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At least you should now be able to run the macro without syntax errors. Otherwise, please don't hesitate to ask again.&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 20:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556216#M154939</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-04T20:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with macros! Trouble using Propensity Score matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556220#M154942</link>
      <description>&lt;P&gt;SAS now has the PSMATCH procedure which should be your starting point, if you have SAS 9.4 TS1M5+.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This link has fully worked examples about half way down.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/app/stat/procedures/psmatch.html" target="_blank"&gt;https://support.sas.com/rnd/app/stat/procedures/psmatch.html&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H2&gt;PSMATCH Procedure&lt;/H2&gt;
&lt;HR /&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Inverse probability of treatment weighting and weighting by the odds.&lt;/LI&gt;
&lt;LI&gt;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.&lt;/LI&gt;
&lt;LI&gt;Matching treated unit with one or more control units that have a similar value of the propensity score.&lt;/LI&gt;
Methods of matching include:
&lt;UL&gt;
&lt;LI&gt;fixed ratio matching&lt;/LI&gt;
&lt;LI&gt;variable ratio matching&lt;/LI&gt;
&lt;LI&gt;full matching&lt;/LI&gt;
&lt;/UL&gt;
&lt;/UL&gt;
&lt;P&gt;Provides various plots for assessing balance. Included plots are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;cloud plots, which are scatter plots in which the points are jittered to prevent overplotting&lt;/LI&gt;
&lt;LI&gt;box plots for continuous variables&lt;/LI&gt;
&lt;LI&gt;bar charts for classification variables&lt;/LI&gt;
&lt;LI&gt;a standardized differences plot that summarizes differences between the treated and control groups&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 04 May 2019 21:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-macros-Trouble-using-Propensity-Score-matching/m-p/556220#M154942</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-04T21:10:12Z</dc:date>
    </item>
  </channel>
</rss>

