<?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: listed variables within a do loop macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440516#M28434</link>
    <description>&lt;P&gt;The %do construct does not have the functionality to do lists of values, that is a datastep do loop only.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you doing it this way, Base SAS is the programming language and has the full functionality, macro is not a replacement for this.&lt;/P&gt;
&lt;P&gt;If you want sums by month, then you would use proc means/summary, by month, then if you need a transposed output for a report (as working with transposed data is more complicated than with normalised data) you can use proc transpose to transpose the data at that point.&amp;nbsp; Zero need for macro, smaller easier to maintain code, and faster as it is using the actual programming language.&lt;/P&gt;
&lt;P&gt;if you provide some test data I can show you the code.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2018 14:50:07 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-02-27T14:50:07Z</dc:date>
    <item>
      <title>listed variables within a do loop macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440514#M28433</link>
      <description>&lt;P&gt;I'm trying to create a list of statistics for all months within my data set. I have everything by month so just need to assign the values to be manipulated further on. The code I'm trying to use is below, but it's not working as it says there is no corresponding %to statement for the initial %do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do stat='sum_of_x','sum_of_y','count_of_x','count_of_y','total_z';&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%do y=13 %to 18;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %do m=1 %to 12;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let mym = %sysfunc(putn(&amp;amp;m,z2.));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%if &amp;amp;y&amp;amp;mym&amp;lt;=1802 %then %do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,sum(&amp;amp;stat) as &amp;amp;stat_&amp;amp;y&amp;amp;mym&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;%end;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 14:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440514#M28433</guid>
      <dc:creator>bethsmith</dc:creator>
      <dc:date>2018-02-27T14:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: listed variables within a do loop macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440516#M28434</link>
      <description>&lt;P&gt;The %do construct does not have the functionality to do lists of values, that is a datastep do loop only.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you doing it this way, Base SAS is the programming language and has the full functionality, macro is not a replacement for this.&lt;/P&gt;
&lt;P&gt;If you want sums by month, then you would use proc means/summary, by month, then if you need a transposed output for a report (as working with transposed data is more complicated than with normalised data) you can use proc transpose to transpose the data at that point.&amp;nbsp; Zero need for macro, smaller easier to maintain code, and faster as it is using the actual programming language.&lt;/P&gt;
&lt;P&gt;if you provide some test data I can show you the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 14:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440516#M28434</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-27T14:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: listed variables within a do loop macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440519#M28435</link>
      <description>&lt;P&gt;If you want to perform a macro language %DO loop over a list of values,&amp;nbsp;you have to program it yourself.&amp;nbsp; Here's some help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 14:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440519#M28435</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-27T14:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: listed variables within a do loop macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440537#M28436</link>
      <description>&lt;P&gt;Consider using PROC MEANS or SUMMARY instead, they're typically a lot more flexible in how you can calculate summary statistics.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134207"&gt;@bethsmith&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to create a list of statistics for all months within my data set. I have everything by month so just need to assign the values to be manipulated further on. The code I'm trying to use is below, but it's not working as it says there is no corresponding %to statement for the initial %do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do stat='sum_of_x','sum_of_y','count_of_x','count_of_y','total_z';&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%do y=13 %to 18;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %do m=1 %to 12;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let mym = %sysfunc(putn(&amp;amp;m,z2.));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%if &amp;amp;y&amp;amp;mym&amp;lt;=1802 %then %do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,sum(&amp;amp;stat) as &amp;amp;stat_&amp;amp;y&amp;amp;mym&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;%end;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 15:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/listed-variables-within-a-do-loop-macro/m-p/440537#M28436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-27T15:52:46Z</dc:date>
    </item>
  </channel>
</rss>

