<?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: do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422220#M103817</link>
    <description>&lt;P&gt;Why do it that way in the first place?&amp;nbsp; SAS i built on the concept of by group processing, which is simpler coding, more robust, and faster.&lt;/P&gt;
&lt;PRE&gt;proc anova data=...;
  by avisitn;
  class ...;
  model Relief = .../...;
run;&lt;/PRE&gt;
&lt;P&gt;That code can replace all of what you have from %let onward.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2017 09:03:22 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-12-19T09:03:22Z</dc:date>
    <item>
      <title>do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422217#M103815</link>
      <description>&lt;P&gt;i want to run the macro %anova_wocf_mi in several visits. But the program only execute one time (where avisitn=6). Is any issue with my program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data avisit;
  length paramcd  chg $8;
  mi=1;
  paramcd = "NPS0203";
  do i =6, 7, 8, 9, 10; 
    avisitn = i;
	chg=compress(catx('','chg',i));
    output;
  end;
  paramcd = "LMS0108";
  do i =8, 10; 
    avisitn = i;
	chg=compress(catx('','chg',i));
    output;
  end;
  paramcd = "UPSIT101";
   do i =3, 6, 7, 8, 10; 
    avisitn = i;
	chg=compress(catx('','chg',i));
    output;
  end;
  paramcd = "FEV1";
   do i = 6, 7, 8, 10; 
    avisitn = i;
	chg=compress(catx('','chg',i));
    output;
  end;
run;

%let paramcd=NPS0203;

 proc sql noprint;
    select  avisitn into: vis separated by "-"
        from avisit
            where paramcd="&amp;amp;paramcd." 
    ;
quit;

%put &amp;amp;vis;

%include mac_a(anova_wocf_mi.sas);

%macro loop;
    %do i=1 %to %sysfunc(countw(&amp;amp;vis,%str(-)));
        %let ppp=%scan(&amp;amp;vis,&amp;amp;i, -);
        %put &amp;amp;ppp;
		%anova_wocf_mi(paramcd=NPS0203, avisitn=&amp;amp;ppp., censornum=2, popoth=);
		%end;
%mend loop;
%loop;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Dec 2017 08:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422217#M103815</guid>
      <dc:creator>Juanjuan</dc:creator>
      <dc:date>2017-12-19T08:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422220#M103817</link>
      <description>&lt;P&gt;Why do it that way in the first place?&amp;nbsp; SAS i built on the concept of by group processing, which is simpler coding, more robust, and faster.&lt;/P&gt;
&lt;PRE&gt;proc anova data=...;
  by avisitn;
  class ...;
  model Relief = .../...;
run;&lt;/PRE&gt;
&lt;P&gt;That code can replace all of what you have from %let onward.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 09:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422220#M103817</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-19T09:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422226#M103818</link>
      <description>&lt;P&gt;Thanks a lot. this is because before the model, we have to impute the data by MI and WOCF which is different by different visits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue has been fixed now. that's because there is another do loop which use i as index in %anova_wocf_mi macro. if i is replaced by jj, then the do loop will be fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro loop;
    %do jj=1 %to %sysfunc(countw(&amp;amp;vis,%str(-)));
        %let visn=%scan(&amp;amp;vis,&amp;amp;jj, -);
        %put &amp;amp;visn;
		%ancova_wocf_mi(paramcd=NPS0203, avisitn=&amp;amp;visn., censornum=2, popoth=);
		%end;
%mend loop;
%loop;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 09:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/422226#M103818</guid>
      <dc:creator>Juanjuan</dc:creator>
      <dc:date>2017-12-19T09:18:08Z</dc:date>
    </item>
  </channel>
</rss>

