<?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: Problem wrapping Proc GLM in a macro (using ODS output) in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242186#M15022</link>
    <description>&lt;P&gt;You do not need to use ODS OUTPUT CLOSE at all. PROC GLM is an interactive procedure, so it does not write certain files or create certain output until the procedure exits.&amp;nbsp; Change to RUN statement to a QUIT statement and you should get all the output without having to CLOSE the ODS destination.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2016 14:05:04 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-01-07T14:05:04Z</dc:date>
    <item>
      <title>Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242088#M15012</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to report the anova results from PROC GLM in a dataset using ODS. If I use only one variable (p_total_a, looking to see if it differs across 13 different ID groups), what I am trying to do works perfectly (code below):&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;trace&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;label&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; modelanova=output;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;glm&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;=dataset;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; id; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;model&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; p_total_a = id;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;lsmeans&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; id; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;close&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;trace&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;off&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I have multiple variables that I need to do this for, so I tried to wrap the procedure in a Macro, but it only creates one output dataset instead of multiple (only for the first variable I run through the macro). If I check the log, after the first iteration of the macro with the first variable, I get a warning message that reads:&lt;/P&gt;&lt;P&gt;WARNING: Output 'modelanova' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,&lt;/P&gt;&lt;P&gt;verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.&lt;/P&gt;&lt;P&gt;WARNING: The current ODS SELECT/EXCLUDE/OUTPUT statement was cleared because the end of a procedure step was detected. Probable causes for this include the non-termination of an interactive procedure (type quit; to end the procedure) and a run group with no output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I am using for the macro. Any suggestions welcome. Thank you!&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;trace&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;label&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; macro(var=);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ods output modelanova=output_&amp;amp;var;&lt;/P&gt;&lt;P&gt;proc glm data=dataset;&lt;/P&gt;&lt;P&gt;class id;&lt;/P&gt;&lt;P&gt;model &amp;amp;var = id;&lt;/P&gt;&lt;P&gt;lsmeans id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ods output close;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; macro;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ods&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;trace&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;off&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;macro&lt;/I&gt;&lt;/STRONG&gt;(var=p_total_a)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;macro&lt;/I&gt;&lt;/STRONG&gt;(var=p_total_b)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 18:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242088#M15012</guid>
      <dc:creator>osi814</dc:creator>
      <dc:date>2016-01-06T18:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242092#M15014</link>
      <description>&lt;P&gt;Move&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to outside your macro. You close it on the first iteration, so your destination is no longer open for any output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods trace on / label;
%macro macro(var=);
ods output modelanova=output_&amp;amp;var;
proc glm data=dataset;
class id;
model &amp;amp;var = id;
lsmeans id;
run;

%mend macro;
ods trace off;
%macro(var=p_total_a)
%macro(var=p_total_b)

ods output close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 18:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242092#M15014</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-06T18:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242097#M15016</link>
      <description>&lt;P&gt;Thank you for your suggestion and reply! I just tried running your edited program, but I got the same warning message and it still only produced one output&amp;nbsp;dataset for the first variable.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 18:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242097#M15016</guid>
      <dc:creator>osi814</dc:creator>
      <dc:date>2016-01-06T18:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242103#M15018</link>
      <description>&lt;P&gt;I tried running your code - it generated errors, macro name for one. Fixing those and moving ods table inside seemed to generate results. I can't recall at the moment what the ODS OUTPUT statement does, but I think closing it caused issues. I don't think it does what your thinking as well...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for me, good luck:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro repeat_glm(var=);

proc glm data=sashelp.class;
class sex;
model &amp;amp;var = sex;
lsmeans sex;
ods table modelanova=output_&amp;amp;var;
run;
ods trace off;
%mend repeat_glm;

%repeat_glm(var=age)
%repeat_glm(var=weight)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jan 2016 18:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242103#M15018</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-06T18:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242106#M15020</link>
      <description>&lt;P&gt;Thank you so much Reeza! That worked for my program. I had made up that macro name for this forum so it was easier to read but guess that wasn't the best idea &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 18:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242106#M15020</guid>
      <dc:creator>osi814</dc:creator>
      <dc:date>2016-01-06T18:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242186#M15022</link>
      <description>&lt;P&gt;You do not need to use ODS OUTPUT CLOSE at all. PROC GLM is an interactive procedure, so it does not write certain files or create certain output until the procedure exits.&amp;nbsp; Change to RUN statement to a QUIT statement and you should get all the output without having to CLOSE the ODS destination.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 14:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242186#M15022</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-07T14:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem wrapping Proc GLM in a macro (using ODS output)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242194#M15023</link>
      <description>&lt;P&gt;Thank you Rick for your reply and explanation!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 14:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Problem-wrapping-Proc-GLM-in-a-macro-using-ODS-output/m-p/242194#M15023</guid>
      <dc:creator>osi814</dc:creator>
      <dc:date>2016-01-07T14:51:59Z</dc:date>
    </item>
  </channel>
</rss>

