<?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 the last item in my loop was not executed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274768#M54881</link>
    <description>&lt;P&gt;I have a number of variables that were log transformed, and I wanted to use these new variables to do ANOVA.&lt;/P&gt;
&lt;P&gt;I first created a macro variable to store all the log transformed variables names and then used a do loop to repeat the anova analysis.&lt;/P&gt;
&lt;P&gt;The problem is, my last log variables was not included in the anova analysis. I checked the values of the macro variables "collist" and "n", which were both correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What could be the problem?&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;
%macro loop_var(data);
proc contents data=&amp;amp;data short out=test; run;
proc sql;
select name into :collist separated by ' '
from test
where name like 'log_%';
%let n=&amp;amp;sqlobs;
quit;
ods graphics off;
%do i=1 %to &amp;amp;n;
    %let currentvar=%scan(&amp;amp;collist,&amp;amp;i);
proc glm data=&amp;amp;data ;
class type;
model &amp;amp;currentvar=type;
lsmeans type /pdiff stderr cl ADJUST=SCHEFFE;
%end;
%mend;

%loop_var(mydata);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Jun 2016 19:04:38 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2016-06-02T19:04:38Z</dc:date>
    <item>
      <title>the last item in my loop was not executed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274768#M54881</link>
      <description>&lt;P&gt;I have a number of variables that were log transformed, and I wanted to use these new variables to do ANOVA.&lt;/P&gt;
&lt;P&gt;I first created a macro variable to store all the log transformed variables names and then used a do loop to repeat the anova analysis.&lt;/P&gt;
&lt;P&gt;The problem is, my last log variables was not included in the anova analysis. I checked the values of the macro variables "collist" and "n", which were both correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What could be the problem?&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;
%macro loop_var(data);
proc contents data=&amp;amp;data short out=test; run;
proc sql;
select name into :collist separated by ' '
from test
where name like 'log_%';
%let n=&amp;amp;sqlobs;
quit;
ods graphics off;
%do i=1 %to &amp;amp;n;
    %let currentvar=%scan(&amp;amp;collist,&amp;amp;i);
proc glm data=&amp;amp;data ;
class type;
model &amp;amp;currentvar=type;
lsmeans type /pdiff stderr cl ADJUST=SCHEFFE;
%end;
%mend;

%loop_var(mydata);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274768#M54881</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-06-02T19:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: the last item in my loop was not executed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274770#M54882</link>
      <description>&lt;P&gt;What values do you have for collist and n?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps add:&lt;/P&gt;
&lt;PRE&gt;%put collist=&amp;amp;collist i=&amp;amp;i currentvar=&amp;amp;currentvar n=&amp;amp;n;&lt;/PRE&gt;
&lt;P&gt;Immediately before your PROC GLM statement.&amp;nbsp; That should help debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274770#M54882</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-06-02T19:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: the last item in my loop was not executed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274772#M54884</link>
      <description>&lt;P&gt;Try adding&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;at the end of the Proc Glm code. You may not be running into a "boundary" to tell the procedure that the last one ended.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274772#M54884</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-02T19:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: the last item in my loop was not executed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274795#M54887</link>
      <description>&lt;P&gt;yes. this solved the problem. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-last-item-in-my-loop-was-not-executed/m-p/274795#M54887</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-06-02T20:20:10Z</dc:date>
    </item>
  </channel>
</rss>

