<?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: Unclosed Do loop in Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unclosed-Do-loop-in-Macro/m-p/445986#M111833</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156653"&gt;@abak&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;For some reason this claims I have an unclosed DO loop. I am admittedly a SAS noob. I searched the board but didn't see anything that helped me answer the question (though I'm sure there must be this answer somewhere).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data has two columns of interest- shortname (a groupingv variable) and the data in two datasets- ASet and CSet (they contain the same columns).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before this code, there are macro variables vcshortname1, vcshortname2....vcshortname10 pre-defined.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro mac;&lt;BR /&gt;&amp;nbsp;%do i=1 %to 10;&lt;BR /&gt;&amp;nbsp;/* Separate by shortname, then run permutation test on each shortname*/&lt;BR /&gt;&amp;nbsp;data G1;&lt;BR /&gt;&amp;nbsp;set ASet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;data G2;&lt;BR /&gt;&amp;nbsp;set CSet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*This should END the loop!*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT color="#ff0000" size="5"&gt;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*Running code for permutation test. Got it from the community board*/&lt;BR /&gt;&amp;nbsp;proc IML;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;obsdiff = mean(G1) = mean(G2);&lt;BR /&gt;&amp;nbsp;alldata = G1 // G2; /* stack data in a single vector */&lt;BR /&gt;&amp;nbsp;N1 = nrow(G1); N = N1 + nrow(G2);&lt;BR /&gt;&amp;nbsp;NRepl = 9999; /* number of permutations */&lt;BR /&gt;&amp;nbsp;nulldist = j(NRepl,1); /* allocate vector to hold results */&lt;BR /&gt;&amp;nbsp;do k = 1 to NRepl;&lt;BR /&gt;&amp;nbsp;x = sample(alldata, N, "WOR"); /* permute the data */&lt;BR /&gt;&amp;nbsp;nulldist[k] = mean(x[1:N1]) - mean(x[(N1+1):N]); /* difference of means */&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;pval = (1 + sum(abs(nulldist) &amp;gt;= abs(obsdiff))) / (NRepl+1);&lt;BR /&gt;&amp;nbsp;print pval;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;title "Histogram of Null Distribution";&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;refline = "refline " + char(obsdiff) + " / axis=x lineattrs=(color=red);";&lt;BR /&gt;&amp;nbsp;call Histogram(nulldist) other=refline;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;quit;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;%mend mac;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mac&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please see the highlighted text for how to end a %DO loop.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 20:08:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-15T20:08:36Z</dc:date>
    <item>
      <title>Unclosed Do loop in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unclosed-Do-loop-in-Macro/m-p/445984#M111831</link>
      <description>&lt;P&gt;For some reason this claims I have an unclosed DO loop. I am admittedly a SAS noob. I searched the board but didn't see anything that helped me answer the question (though I'm sure there must be this answer somewhere).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data has two columns of interest- shortname (a groupingv variable) and the data in two datasets- ASet and CSet (they contain the same columns).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before this code, there are macro variables vcshortname1, vcshortname2....vcshortname10 pre-defined.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro mac;&lt;BR /&gt;&amp;nbsp;%do i=1 %to 10;&lt;BR /&gt;&amp;nbsp;/* Separate by shortname, then run permutation test on each shortname*/&lt;BR /&gt;&amp;nbsp;data G1;&lt;BR /&gt;&amp;nbsp;set ASet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;data G2;&lt;BR /&gt;&amp;nbsp;set CSet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*This should END the loop!*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Running code for permutation test. Got it from the community board*/&lt;BR /&gt;&amp;nbsp;proc IML;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;obsdiff = mean(G1) = mean(G2);&lt;BR /&gt;&amp;nbsp;alldata = G1 // G2; /* stack data in a single vector */&lt;BR /&gt;&amp;nbsp;N1 = nrow(G1); N = N1 + nrow(G2);&lt;BR /&gt;&amp;nbsp;NRepl = 9999; /* number of permutations */&lt;BR /&gt;&amp;nbsp;nulldist = j(NRepl,1); /* allocate vector to hold results */&lt;BR /&gt;&amp;nbsp;do k = 1 to NRepl;&lt;BR /&gt;&amp;nbsp;x = sample(alldata, N, "WOR"); /* permute the data */&lt;BR /&gt;&amp;nbsp;nulldist[k] = mean(x[1:N1]) - mean(x[(N1+1):N]); /* difference of means */&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;pval = (1 + sum(abs(nulldist) &amp;gt;= abs(obsdiff))) / (NRepl+1);&lt;BR /&gt;&amp;nbsp;print pval;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;title "Histogram of Null Distribution";&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;refline = "refline " + char(obsdiff) + " / axis=x lineattrs=(color=red);";&lt;BR /&gt;&amp;nbsp;call Histogram(nulldist) other=refline;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;quit;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;%mend mac;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mac&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 20:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unclosed-Do-loop-in-Macro/m-p/445984#M111831</guid>
      <dc:creator>abak</dc:creator>
      <dc:date>2018-03-15T20:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Unclosed Do loop in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unclosed-Do-loop-in-Macro/m-p/445986#M111833</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156653"&gt;@abak&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;For some reason this claims I have an unclosed DO loop. I am admittedly a SAS noob. I searched the board but didn't see anything that helped me answer the question (though I'm sure there must be this answer somewhere).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data has two columns of interest- shortname (a groupingv variable) and the data in two datasets- ASet and CSet (they contain the same columns).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before this code, there are macro variables vcshortname1, vcshortname2....vcshortname10 pre-defined.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro mac;&lt;BR /&gt;&amp;nbsp;%do i=1 %to 10;&lt;BR /&gt;&amp;nbsp;/* Separate by shortname, then run permutation test on each shortname*/&lt;BR /&gt;&amp;nbsp;data G1;&lt;BR /&gt;&amp;nbsp;set ASet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;data G2;&lt;BR /&gt;&amp;nbsp;set CSet;&lt;BR /&gt;&amp;nbsp;if shortname = &amp;amp;&amp;amp;vcshortname.&amp;amp;i;&lt;BR /&gt;&amp;nbsp;keep data;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*This should END the loop!*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT color="#ff0000" size="5"&gt;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*Running code for permutation test. Got it from the community board*/&lt;BR /&gt;&amp;nbsp;proc IML;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;obsdiff = mean(G1) = mean(G2);&lt;BR /&gt;&amp;nbsp;alldata = G1 // G2; /* stack data in a single vector */&lt;BR /&gt;&amp;nbsp;N1 = nrow(G1); N = N1 + nrow(G2);&lt;BR /&gt;&amp;nbsp;NRepl = 9999; /* number of permutations */&lt;BR /&gt;&amp;nbsp;nulldist = j(NRepl,1); /* allocate vector to hold results */&lt;BR /&gt;&amp;nbsp;do k = 1 to NRepl;&lt;BR /&gt;&amp;nbsp;x = sample(alldata, N, "WOR"); /* permute the data */&lt;BR /&gt;&amp;nbsp;nulldist[k] = mean(x[1:N1]) - mean(x[(N1+1):N]); /* difference of means */&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;pval = (1 + sum(abs(nulldist) &amp;gt;= abs(obsdiff))) / (NRepl+1);&lt;BR /&gt;&amp;nbsp;print pval;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;title "Histogram of Null Distribution";&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;refline = "refline " + char(obsdiff) + " / axis=x lineattrs=(color=red);";&lt;BR /&gt;&amp;nbsp;call Histogram(nulldist) other=refline;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;quit;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;%mend mac;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mac&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please see the highlighted text for how to end a %DO loop.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 20:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unclosed-Do-loop-in-Macro/m-p/445986#M111833</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-15T20:08:36Z</dc:date>
    </item>
  </channel>
</rss>

