<?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: SAS macro not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938447#M368617</link>
    <description>&lt;P&gt;You seem to have converted the first line of the macro definition into two separate statements.&amp;nbsp; The result is something that probably could never work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what that article has as the first line of the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro itsa(model=, dataset=, outcome=, outcome2=, time=, interrupt=, lag=);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have the whole macro defined then you can try to call it:&lt;/P&gt;
&lt;P&gt;So the structure&amp;nbsp; of your code should be something more like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro itsa(model=, dataset=, outcome=, outcome2=, time=, interrupt=, lag=);
.... rest of the body of the macro ...
%mend itsa;

... Code that set up the datasets link ID4 that you want to use ...

* Call to the macro ;
%itsa(model=sitsa, dataset=work.ID4, outcome=burnout, time=Week, interrupt=14);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Aug 2024 23:30:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-08-06T23:30:37Z</dc:date>
    <item>
      <title>SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938425#M368609</link>
      <description>&lt;P&gt;Good day,&lt;/P&gt;&lt;P&gt;I want to use a macro developed by someone else to conduct an interrupted time series analysis. It runs fine but there is no output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if I run the first portion using my dataset, it doesn't save the macro data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would anyone please shed light on why its not saving the data?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro itsa;&lt;BR /&gt;%itsa(model=sitsa, dataset=work.ID4, outcome=burnout, time=Week, interrupt=14);&lt;BR /&gt;%if (&amp;amp;model=sitsa) %then %do;&lt;BR /&gt;data work.sitsa_vars;&lt;BR /&gt;set &amp;amp;dataset;&lt;BR /&gt;t=_n_;&lt;BR /&gt;if &amp;amp;time&amp;lt; &amp;amp;interrupt then x=0;&lt;BR /&gt;else x=1;&lt;BR /&gt;if &amp;amp;time&amp;lt;&amp;amp;interrupt then tx=0;&lt;BR /&gt;else tx+1;&lt;BR /&gt;keep &amp;amp;time &amp;amp;outcome t x tx;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on Appendix in&amp;nbsp;&lt;A href="https://www.linkedin.com/pulse/interrupted-time-series-analysis-single-comparative-designs-caswell-1/" target="_blank"&gt;Interrupted Time Series Analysis for Single Series and Comparative Designs: A Guide for Beginners with SAS Macro (linkedin.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 20:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938425#M368609</guid>
      <dc:creator>Nia2023</dc:creator>
      <dc:date>2024-08-06T20:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938426#M368610</link>
      <description>&lt;P&gt;The macro code you've posted appears to be incomplete. For example, it contains no %MEND statement to close off the macro. You also appear to be calling the macro from inside the macro itelf which is never a good idea. This should "work" but still appears to be incomplete:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro itsa (model=, dataset=, outcome=, time=, interrupt=);

%if (&amp;amp;model=sitsa) %then %do;

data work.sitsa_vars;
set &amp;amp;dataset;
t=_n_;
if &amp;amp;time&amp;lt; &amp;amp;interrupt then x=0;
else x=1;
if &amp;amp;time&amp;lt;&amp;amp;interrupt then tx=0;
else tx+1;
keep &amp;amp;time &amp;amp;outcome t x tx;

%end;
run;

%mend itsa; 

%itsa(model=sitsa, dataset=work.ID4, outcome=burnout, time=Week, interrupt=14);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2024 21:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938426#M368610</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-08-06T21:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938434#M368611</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just tried the code, it runs but no new data set is saved nor output produced.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the actual macro is longer, as provided in the Appendix linked above. I was just trying to figure out the first part.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The entire macro doesn't work either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 21:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938434#M368611</guid>
      <dc:creator>Nia2023</dc:creator>
      <dc:date>2024-08-06T21:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938443#M368614</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;/&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;/&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And when MACRO coding is involved then turn on OPTIONS MPRINT; before running the code so the log will show the generated code (and warning or error messages in closer proximity to the code causing them).&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 22:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938443#M368614</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-06T22:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938447#M368617</link>
      <description>&lt;P&gt;You seem to have converted the first line of the macro definition into two separate statements.&amp;nbsp; The result is something that probably could never work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what that article has as the first line of the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro itsa(model=, dataset=, outcome=, outcome2=, time=, interrupt=, lag=);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have the whole macro defined then you can try to call it:&lt;/P&gt;
&lt;P&gt;So the structure&amp;nbsp; of your code should be something more like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro itsa(model=, dataset=, outcome=, outcome2=, time=, interrupt=, lag=);
.... rest of the body of the macro ...
%mend itsa;

... Code that set up the datasets link ID4 that you want to use ...

* Call to the macro ;
%itsa(model=sitsa, dataset=work.ID4, outcome=burnout, time=Week, interrupt=14);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2024 23:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938447#M368617</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-06T23:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938451#M368619</link>
      <description>&lt;P&gt;Thank you! This may indeed be the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked! After restarting SAS session and running it as suggested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 01:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938451#M368619</guid>
      <dc:creator>Nia2023</dc:creator>
      <dc:date>2024-08-07T01:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938452#M368620</link>
      <description>&lt;P&gt;There are no errors, no notes, nothing in the log. Just the code lines in black.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 01:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-not-working/m-p/938452#M368620</guid>
      <dc:creator>Nia2023</dc:creator>
      <dc:date>2024-08-07T01:16:50Z</dc:date>
    </item>
  </channel>
</rss>

