<?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: Macro within a Macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266068#M52390</link>
    <description>&lt;P&gt;No, I don't need to access it outside the macro. After running that code, I typed %put chi1, and i got the error:&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;WARNING: Apparent symbolic reference CHI1 not resolved.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2016 15:18:37 GMT</pubDate>
    <dc:creator>bts</dc:creator>
    <dc:date>2016-04-25T15:18:37Z</dc:date>
    <item>
      <title>Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266049#M52383</link>
      <description>&lt;P&gt;I'm having trouble with the following symputx statement. I'm looking to end up with macros for each of the 4 chi square values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt; proc_code (i);&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;ods output chisq=chia&amp;amp;i;&lt;/P&gt;
&lt;P class="p2"&gt;proc freq data=collapsed_values;&lt;/P&gt;
&lt;P class="p2"&gt;tables discuss_pay*gender/chisq;&lt;/P&gt;
&lt;P class="p2"&gt;where discuss_pay ne &lt;SPAN class="s2"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt; and gender=&lt;SPAN class="s2"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; or gender=&lt;SPAN class="s2"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p2"&gt;run;&lt;/P&gt;
&lt;P class="p2"&gt;quit;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;data _null_;set chia&amp;amp;i;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;format tmp &lt;SPAN class="s2"&gt;$40.&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if Statistic=&lt;SPAN class="s3"&gt;"Chi-Square"&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=put(prob,&lt;SPAN class="s2"&gt;&lt;STRONG&gt;6.4&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob &amp;lt;&lt;SPAN class="s2"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp= &lt;SPAN class="s3"&gt;"&amp;lt;.001"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob &amp;lt;&lt;SPAN class="s2"&gt;&lt;STRONG&gt;.0001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp= &lt;SPAN class="s3"&gt;"&amp;lt;.001"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob gt &lt;SPAN class="s2"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=trim(catt(round(prob,&lt;SPAN class="s2"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt;)));&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=catt(&lt;SPAN class="s3"&gt;"Chi-Square Results CHISQ"&lt;/SPAN&gt;,&lt;SPAN class="s3"&gt;"("&lt;/SPAN&gt;,DF,&lt;SPAN class="s3"&gt;")="&lt;/SPAN&gt;,round(value,&lt;SPAN class="s2"&gt;&lt;STRONG&gt;.01&lt;/STRONG&gt;&lt;/SPAN&gt;),&lt;SPAN class="s3"&gt;" p"&lt;/SPAN&gt;,tmp);&lt;/P&gt;
&lt;P class="p3"&gt;call symputx('chi&amp;amp;i',tmp);&lt;/P&gt;
&lt;P class="p2"&gt;end;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RUN;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;SPAN class="s5"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt; (&lt;SPAN class="s2"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P class="p2"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt; (&lt;STRONG&gt;2&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt; (&lt;STRONG&gt;3&lt;/STRONG&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN&gt;&lt;SPAN&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt; (&lt;STRONG&gt;4&lt;/STRONG&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 14:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266049#M52383</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T14:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266054#M52384</link>
      <description>&lt;P&gt;I don't see how this will work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your WHERE condition is incorrect, and if you're always running the same proc with the same table statement the values won't differ regardless of your i value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;ods output chisq=chia&amp;amp;i;&lt;/P&gt;
&lt;P class="p2"&gt;proc freq data=collapsed_values;&lt;/P&gt;
&lt;P class="p2"&gt;tables discuss_pay*gender/chisq;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;STRONG&gt;where discuss_pay ne &lt;SPAN class="s2"&gt;.&lt;/SPAN&gt; and gender=&lt;SPAN class="s2"&gt;1&lt;/SPAN&gt; or gender=&lt;SPAN class="s2"&gt;2&lt;/SPAN&gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p2"&gt;run;&lt;/P&gt;
&lt;P class="p2"&gt;quit;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;I think this is what you want&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;STRONG&gt;where discuss_pay ne &lt;SPAN class="s2"&gt;.&lt;/SPAN&gt; and gender in (1,2);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;STRONG&gt;You need to change your proc freq somehow I imagine?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266054#M52384</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-25T15:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266056#M52385</link>
      <description>&lt;P&gt;I Assume that mean that you need to access those macro variables outside the macro?&lt;/P&gt;
&lt;P&gt;It's about&amp;nbsp;scope. Macro variable created within a macro&amp;nbsp;exist only in local scope of the macro.&lt;/P&gt;
&lt;P&gt;You need to define them as global.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266056#M52385</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-04-25T15:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266060#M52386</link>
      <description>&lt;P&gt;The proc freq works (i removed the where statement to test it) - it's the macro that doesn't. I tried a %let statement in lieu of the symputx statement, but still no go.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266060#M52386</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266062#M52387</link>
      <description>&lt;P&gt;It may work, but I don't think it's correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266062#M52387</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-25T15:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266065#M52388</link>
      <description>&lt;P&gt;oh i misunderstood - thank you very much for pointing that out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266065#M52388</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266068#M52390</link>
      <description>&lt;P&gt;No, I don't need to access it outside the macro. After running that code, I typed %put chi1, and i got the error:&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;WARNING: Apparent symbolic reference CHI1 not resolved.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266068#M52390</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266071#M52391</link>
      <description>&lt;P&gt;It looks like you plan on calling the macro 4 times.&amp;nbsp; So you don't need your macro to loop through 4 executions automatically.&amp;nbsp; Rather, focus on the PROC FREQ.&amp;nbsp; Each time PROC FREQ runs, it generates exactly the same output.&amp;nbsp; You might use ODS to place that output into a different data set each time, but the output of PROC FREQ doesn't change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you want the results of PROC FREQ to change each time you call the macro?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266071#M52391</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-25T15:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266073#M52392</link>
      <description>&lt;P&gt;Linus is right about that part.&amp;nbsp; Once the macro finishes, your macro variables disappear with it.&amp;nbsp; You could put this statement inside the macro instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;&amp;amp;chi&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you will still find that &amp;amp;chi1 is equal to &amp;amp;chi2 is equal to &amp;amp;chi3 is equal to &amp;amp;chi4.&amp;nbsp; The output of PROC FREQ never changes.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266073#M52392</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-25T15:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266075#M52393</link>
      <description>&lt;P&gt;I have another macro variable (&amp;amp;var) that cycles through a list of variables to be used in the proc freq. Although I used 4 in the example I posted, there are actually 60 variables, hence 60 chi square statistics that I want outputed chi1-chi60. So I thought I could output a macro variable that represents the 60 chi-squares.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt; proc_code(var,i);&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;ods output chisq=chi&amp;amp;i;&lt;/P&gt;
&lt;P class="p2"&gt;proc freq data=pd.griffin_collapsed_values;&lt;/P&gt;
&lt;P class="p2"&gt;tables &amp;amp;var*gender/chisq;&lt;/P&gt;
&lt;P class="p2"&gt;run;&lt;/P&gt;
&lt;P class="p2"&gt;quit;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;data _null_;set chia&amp;amp;i;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;format tmp &lt;SPAN class="s1"&gt;$40.&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if Statistic=&lt;SPAN class="s2"&gt;"Chi-Square"&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=put(prob,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;6.4&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob &amp;lt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp= &lt;SPAN class="s2"&gt;"&amp;lt;.001"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob &amp;lt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;.0001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp= &lt;SPAN class="s2"&gt;"&amp;lt;.001"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if prob gt &lt;SPAN class="s1"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt; then do;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=trim(catt(round(prob,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;.001&lt;/STRONG&gt;&lt;/SPAN&gt;)));&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;tmp=catt(&lt;SPAN class="s2"&gt;"Chi-Square Results CHISQ"&lt;/SPAN&gt;,&lt;SPAN class="s2"&gt;"("&lt;/SPAN&gt;,DF,&lt;SPAN class="s2"&gt;")="&lt;/SPAN&gt;,round(value,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;.01&lt;/STRONG&gt;&lt;/SPAN&gt;),&lt;SPAN class="s2"&gt;" p"&lt;/SPAN&gt;,tmp);&lt;/P&gt;
&lt;P class="p1"&gt;call symputx(&lt;SPAN class="s2"&gt;'chi&amp;amp;i'&lt;/SPAN&gt;,tmp);&lt;/P&gt;
&lt;P class="p1"&gt;end;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RUN; &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt;( discuss_pay,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;);&lt;/P&gt;
&lt;P class="p1"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt;( doc_language,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P class="p1"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt;( undstd_docs,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;);&lt;/P&gt;
&lt;P class="p1"&gt;%&lt;STRONG&gt;&lt;I&gt;proc_code&lt;/I&gt;&lt;/STRONG&gt;( undstd_role,&lt;SPAN class="s1"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266075#M52393</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266078#M52395</link>
      <description>&lt;P&gt;When I add&amp;nbsp;%put &amp;amp;&amp;amp;chi&amp;amp;i; within the macro, it returns a value of "tmp".&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266078#M52395</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266084#M52399</link>
      <description>&lt;P&gt;Why a macro? Why not just run them all at once?&lt;/P&gt;
&lt;P&gt;Whatever you're using the macro variables for later, it's probably easier if you have them all in a table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output chisq=chi;
proc freq data=sashelp.cars;
tables (cylinders type origin)*make/chisq;
run;
quit;

data chi;
set chi;

variable = scan(table, 2, " *");
where Statistic="Chi-Square";
run;

proc print data=chi;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266084#M52399</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-25T15:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266087#M52401</link>
      <description>&lt;P&gt;Because after the chi-squares and before the macro ends, I'm creating graphs and will be putting their chi-square statistic in footnotes to each graph.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266087#M52401</guid>
      <dc:creator>bts</dc:creator>
      <dc:date>2016-04-25T15:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266089#M52402</link>
      <description>&lt;P&gt;Sorry, I think there is a lot of unecessary code in there. &amp;nbsp;Why are you calling the macro 4 times to start with, you get the same output for each loop as the freq is exactly the same for each call?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods output chisq=chia;&lt;BR /&gt;proc freq data=collapsed_values;&lt;BR /&gt; tables discuss_pay*gender/chisq;&lt;BR /&gt; where discuss_pay ne . and gender=1 or gender=2;&lt;BR /&gt;run; &lt;BR /&gt;data _null_;&lt;BR /&gt; length tmp $40;&lt;BR /&gt; set chiA;&lt;BR /&gt; if Statistic="Chi-Square" then do;&lt;BR /&gt; tmp=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob &amp;lt;.001,"&amp;lt;.001",strip(round(prob,.001))));&lt;BR /&gt; call symputx('chi',tmp);&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;This is what your code resolves to to my mind, the only thing I can't work out is why the four calls - and why these can't be put into the proc freq? &amp;nbsp;Posting test data, in the form of a datastep, and what the output should look like would help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266089#M52402</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-25T15:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266092#M52403</link>
      <description>&lt;P&gt;Taking into account everything posted so far, two small changes are needed.&amp;nbsp; You have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx('chi&amp;amp;i',tmp);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need to replace this with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx("chi&amp;amp;i",tmp, 'G');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This takes care of two issues.&amp;nbsp; First, macro processing skips over any text in single quotes.&amp;nbsp; So to get &amp;amp;i to resolve, change the single quotes to double quotes.&amp;nbsp; And second, "G" will keep the macro variables around once the macro finishes executing.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/266092#M52403</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-25T15:53:22Z</dc:date>
    </item>
  </channel>
</rss>

