<?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: if within do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328940#M271759</link>
    <description>&lt;P&gt;I'm with Art on this. We need to know what the values of &amp;amp;dep and &amp;amp;ind resolve to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to suspect that something in the IND variable is being created with other code and it actually has part of the code such as %end instead of resolved values to a simple list of variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put dep=&amp;amp;dep&amp;nbsp; ind=&amp;amp;ind; and show the results.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2017 00:28:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-01T00:28:35Z</dc:date>
    <item>
      <title>Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328879#M271754</link>
      <description>&lt;P&gt;Hi I am truing to create a macro with if statement within a do loop but I kept on geeting an error:ERROR: There is no matching %IF statement for the %ELSE.&lt;BR /&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code, any help woul be greatly appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;%do I=1 %TO 20;&lt;BR /&gt;%if &amp;amp;I=1 %then %do;&lt;BR /&gt;...&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;...&lt;BR /&gt;%end;&lt;BR /&gt;%END;&lt;BR /&gt;%MEND test;&lt;BR /&gt;%test;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 21:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328879#M271754</guid>
      <dc:creator>Newph</dc:creator>
      <dc:date>2017-01-31T21:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328882#M271755</link>
      <description>&lt;P&gt;You need to post you whole code. It is very likely that in the body of your suppressed code (the ...) you have made an error such as not closing a quote, ( or missing a semicolon. The error is typical when one of these happens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 21:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328882#M271755</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-31T21:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328906#M271756</link>
      <description>&lt;P&gt;heres the code--thanks in advance for any help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;%do I=1 %TO 20;&lt;/P&gt;&lt;P&gt;%if &amp;amp;I=1 %then %do;&lt;BR /&gt;proc logistic data = mydata order=internal descending outmodel=outdata;&lt;BR /&gt;model &amp;amp;dep =&amp;amp;ind&lt;BR /&gt;/MAXITER=1000000;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%else %do;&lt;BR /&gt;&lt;BR /&gt;proc logistic data = mydata2 order=internal descending outmodel=mydata3;&lt;BR /&gt;model &amp;amp;dep =&amp;amp;ind&lt;BR /&gt;/MAXITER=1000000;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc logistic inmodel=mydata3;&lt;BR /&gt;score clm data = mydata4&amp;nbsp;out=mydata5;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%END;&lt;BR /&gt;%MEND test;&lt;BR /&gt;%test;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328906#M271756</guid>
      <dc:creator>Newph</dc:creator>
      <dc:date>2017-01-31T22:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328915#M271757</link>
      <description>&lt;P&gt;For starters, where are the macro variables &amp;amp;dep and &amp;amp;ind set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't appear to declare either&amp;nbsp;within your macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328915#M271757</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-31T22:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328925#M271758</link>
      <description>&lt;P&gt;I was able to compile your macro with no problems. &amp;nbsp;Could you attach the full log?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also modified the code and just replaced the PROC LOGISTIC with a %PUT statement and it compiled and ran for me with no problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO TEST;
    %DO I=1 %TO 20;
        %IF &amp;amp;I=1 
        %THEN 
            %DO;
                %PUT &amp;amp;=I;
            %END;

        %ELSE 
            %DO;
                %PUT &amp;amp;=I;
            %END;
    %END;
%MEND TEST;
%TEST;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 23:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328925#M271758</guid>
      <dc:creator>Sven111</dc:creator>
      <dc:date>2017-01-31T23:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: if within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328940#M271759</link>
      <description>&lt;P&gt;I'm with Art on this. We need to know what the values of &amp;amp;dep and &amp;amp;ind resolve to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to suspect that something in the IND variable is being created with other code and it actually has part of the code such as %end instead of resolved values to a simple list of variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put dep=&amp;amp;dep&amp;nbsp; ind=&amp;amp;ind; and show the results.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 00:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-if-within-do-loop/m-p/328940#M271759</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-01T00:28:35Z</dc:date>
    </item>
  </channel>
</rss>

