<?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: Invoke SAS Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654697#M196601</link>
    <description>This site has the original paper and code. &lt;BR /&gt;You'll need to find the specific macro yourself though.&lt;BR /&gt;&lt;A href="https://www.hsph.harvard.edu/tyler-vanderweele/tools-and-tutorials/" target="_blank"&gt;https://www.hsph.harvard.edu/tyler-vanderweele/tools-and-tutorials/&lt;/A&gt;</description>
    <pubDate>Mon, 08 Jun 2020 22:56:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-08T22:56:30Z</dc:date>
    <item>
      <title>Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365520#M86819</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble using&amp;nbsp;a SAS macro that was described in a paper. Can you please tell me what step I am missing? Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Valeri 2013:&amp;nbsp;The macro has been developed using SAS Version 9.2. In order to implement mediation analysis via the mediation macro in SAS the investigator first opens a new SAS session and inputs the data, which has to include the outcome, treatment and mediator variables as well as the covariates to be adjusted for in the model. Macro activation requires then the investigator to save the macro script and input information in the statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mediation(data= ,yvar= ,avar= ,mvar= ,cvar= ,a0= ,a1= ,m= ,nc= ,yreg= ,mreg= ,interaction=)
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I prepped my dataset and plugged in the values needed for the macro like this (values aren't important here, i just want to know how to ues this macro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mediation(data=test, yvar=outcome, avar=exposure, mvar=med, cvar=cov, a0=0, a1=1, m=1, nc=1, yreg=logistic, mreg= logistic, interaction=false)
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent invocation of macro MEDIATION not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong? Do I have to define the macro elsewhere? How does SAS know what to do with this macro?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 20:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365520#M86819</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2017-06-08T20:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365526#M86823</link>
      <description>&lt;P&gt;Use of macro has two part, first defining and compiling it make it ready in the session. That would be code that looks like&lt;/P&gt;
&lt;P&gt;%macro macroname(parameters);&lt;/P&gt;
&lt;P&gt;&amp;lt;assorted SAS code&amp;gt;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you&amp;nbsp; would Execute that block of code before using it as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macroname(a b c);&lt;/P&gt;
&lt;P&gt;to use the value a b c as parameter to the macro.&lt;/P&gt;
&lt;P&gt;You will get the error you reference when the compile step has not be executed OR if there was an error when attempting to compile it.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 21:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365526#M86823</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-08T21:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365531#M86826</link>
      <description>&lt;P&gt;It sounds like the piece you are missing is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Macro activation requires then the investigator to save the macro script ... "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you get a copy of the macro and save it somewhere?&amp;nbsp; Did you identify to the program where the macro is stored?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you did save the macro, the simplest way to define it to your program would be to add one line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%include "path to the file holding the macro code";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being done, you should be able to use the macro later in the same program (or in the same EG session).&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 21:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365531#M86826</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-08T21:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365557#M86834</link>
      <description>&lt;P&gt;Macro definition - needs to be run first&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print(dataset_name);

proc print data=&amp;amp;dataset_name noobs label;
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Macro execution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%print(sashelp.class);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 23:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365557#M86834</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-08T23:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365768#M86918</link>
      <description>&lt;P&gt;thank you! i found the script to define the macro.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 17:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365768#M86918</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2017-06-09T17:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365769#M86919</link>
      <description>&lt;P&gt;thank you! i found the script that defines the macro. Now that I have it, the macro definition is very long and takes me about an hour to run each time. do you have suggestions to make this process faster? It's a series of proc reg. I suppressed output to make it run faster, using the followng code. Any other tips?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ODS LISTING close;
ODS RESULTS OFF;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 17:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365769#M86919</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2017-06-09T17:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365770#M86920</link>
      <description>&lt;P&gt;thank you! i found the original macro definition and am trying to run that first.&amp;nbsp;Any tips to make the run time shorter for this macro? I don't want ot delete out any of the comments.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I included this at at the top which is helping some, but it still takes about an hour to run, each time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS LISTING close;&lt;/P&gt;&lt;P&gt;ODS RESULTS OFF;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 17:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/365770#M86920</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2017-06-09T17:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654665#M196590</link>
      <description>&lt;P&gt;Hi I ran into this same issue as well when trying to replicate the macro. If you have the original script, would you be able to share the syntax? Thank you much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 19:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654665#M196590</guid>
      <dc:creator>lindst801</dc:creator>
      <dc:date>2020-06-08T19:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654694#M196599</link>
      <description>Have you checked into PROC CAUSEMED? That may be what you want now instead?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://support.sas.com/kb/59/081.html" target="_blank"&gt;https://support.sas.com/kb/59/081.html&lt;/A&gt;</description>
      <pubDate>Mon, 08 Jun 2020 22:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654694#M196599</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-08T22:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654697#M196601</link>
      <description>This site has the original paper and code. &lt;BR /&gt;You'll need to find the specific macro yourself though.&lt;BR /&gt;&lt;A href="https://www.hsph.harvard.edu/tyler-vanderweele/tools-and-tutorials/" target="_blank"&gt;https://www.hsph.harvard.edu/tyler-vanderweele/tools-and-tutorials/&lt;/A&gt;</description>
      <pubDate>Mon, 08 Jun 2020 22:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/654697#M196601</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-08T22:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/655610#M196695</link>
      <description>&lt;P&gt;Unfortunately, I need to be able to conduct mediation analysis with count data, so I am only able to use Poisson distribution for a binary variables. When I use PROC CAUSALMED, I am unable to get any other output except the CDE, NDS, and NIE transformed. Therefore, I need to be able to get CDE, NDE, and NIE with a Poisson distribution with a log link.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 18:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/655610#M196695</guid>
      <dc:creator>lindst801</dc:creator>
      <dc:date>2020-06-09T18:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/655618#M196699</link>
      <description>Second link includes the source macro then.</description>
      <pubDate>Tue, 09 Jun 2020 19:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invoke-SAS-Macro/m-p/655618#M196699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-09T19:17:42Z</dc:date>
    </item>
  </channel>
</rss>

