<?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/519268#M140626</link>
    <description>&lt;P&gt;unfortunately no!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it changed my input data!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 20:15:56 GMT</pubDate>
    <dc:creator>NazaninSAS</dc:creator>
    <dc:date>2018-12-06T20:15:56Z</dc:date>
    <item>
      <title>Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519248#M140609</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why my code does not go to the loop?&lt;/P&gt;&lt;P&gt;basically, the code should give me 6 reports (one for each region), but it gives me only one report which is total of all regions.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; to &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;case&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"HQ"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"ATLANTIC"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"PACIFIC"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"PRAIRIES"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"ONTARIO"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"QUEBEC"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; as REGION;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count(SI_PRI) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count (PRI)&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;union&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;all&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'TOTAL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; , count(SI_PRI) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI, count (PRI)&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;i=i+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nazanin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519248#M140609</guid>
      <dc:creator>NazaninSAS</dc:creator>
      <dc:date>2018-12-06T19:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519250#M140610</link>
      <description>&lt;P&gt;Did you write this code yourself or did someone give it to you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to be clear, you want six distinct reports, correct?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519250#M140610</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T19:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519252#M140612</link>
      <description>&lt;P&gt;wrote it myself.&lt;/P&gt;&lt;P&gt;this is the original one:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, HQ Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI format=comma10., count (PRI)as PRI format=comma10.,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="HQ"&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, HQ Region';&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="HQ"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, Atlantic Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="ATLANTIC"&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, Atlantic Region';&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="ATLANTIC"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, PACIFIC Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="PACIFIC"&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="PACIFIC"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, ONTARIO Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="ONTARIO"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="ONTARIO"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, PRAIRIES Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="PRAIRIES"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="PRAIRIES"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;title 'Self Identification by Age Group, QUEBEC Region';&lt;/P&gt;&lt;P&gt;select Band2, count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="QUEBEC"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group by Band2&lt;/P&gt;&lt;P&gt;union all&lt;/P&gt;&lt;P&gt;select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,&lt;/P&gt;&lt;P&gt;calculated SI_PRI/calculated PRI "Return rate" format=percent8.1&lt;/P&gt;&lt;P&gt;from work.Si&lt;/P&gt;&lt;P&gt;where REGION="QUEBEC"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;TITLE;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want o combine all together to make it shorter and more efficient.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nazanin&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519252#M140612</guid>
      <dc:creator>NazaninSAS</dc:creator>
      <dc:date>2018-12-06T19:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519256#M140615</link>
      <description>&lt;P&gt;While I am not fund of this approach, here is something that builds on your own code that you are familiar with. It does the job of making the code shorter, while it is still the exact same code that will run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think PROC REPORT is the right tool to use here, but do something like this if you want to keeo your PROC SQL approach &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data callstack;
   length string $1000;
   do region='HQ', 'ATLANTIC', 'PACIFIC', 'PRAIRIES', 'ONTARIO', 'QUEBEC';
      string=compbl(cats(
         "
         proc sql;
         title 'Self Identification by Age Group, ", region, " -Region';
         select Band2, count(SI_PRI) as SI_PRI format=comma10., count (PRI)as PRI format=comma10.,
         calculated SI_PRI/calculated PRI 'Return rate' format=percent8.1
         from work.Si
         where REGION=", region, ";
         title 'Self Identification by Age Group, ", region, " -Region';
         group by Band2
         union all
         select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,
         calculated SI_PRI/calculated PRI 'Return rate' format=percent8.1
         from work.Si
         where REGION=", region, ";
         ;
         TITLE;
         Quit;
         "
         ));
      output;
      call execute(string);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519256#M140615</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T20:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519257#M140616</link>
      <description>&lt;P&gt;Note, the above code is untested, as I do not have any data to work with.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519257#M140616</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T20:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519258#M140617</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223883"&gt;@NazaninSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why my code does not go to the loop?&lt;/P&gt;
&lt;P&gt;basically, the code should give me 6 reports (one for each region), but it gives me only one report which is total of all regions.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; to &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;case&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"HQ"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"ATLANTIC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"PACIFIC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"PRAIRIES"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"ONTARIO"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"QUEBEC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; as REGION;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count(SI_PRI) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count (PRI)&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;union&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;all&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'TOTAL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; , count(SI_PRI) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI, count (PRI)&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;i=i+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Nazanin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you read the log?&lt;/P&gt;
&lt;P&gt;I expect there should have been an error message similar to:&lt;/P&gt;
&lt;PRE&gt;86   do i= 1 to 6;
     --
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
&lt;/PRE&gt;
&lt;P&gt;because DO loops are not supported by Proc SQL. that explains why the loop doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519258#M140617</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-06T20:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519260#M140619</link>
      <description>&lt;P&gt;do/end are&amp;nbsp;&lt;EM&gt;data step&lt;/EM&gt; statements, they don't work in proc sql. Studying the log (Maxim 2) will alert you to this.&lt;/P&gt;
&lt;P&gt;If you want to repeat code, use a %do/%end macro loop.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519260#M140619</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-06T20:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519261#M140620</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried proc tabulate, no luck! and also it was not the good tool. some SAS folks also recommended PROC REPORT. I have to review it!&lt;/P&gt;&lt;P&gt;I was struggling with PROC report as well! do you know the equivalent to PROC report on Enterprise. sometimes, when I use Enterprise, I can figure out the codes foe SAS base.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Nazanin&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519261#M140620</guid>
      <dc:creator>NazaninSAS</dc:creator>
      <dc:date>2018-12-06T20:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519265#M140624</link>
      <description>&lt;P&gt;I'm not sure what you mean by "&lt;SPAN&gt;the equivalent to PROC report on Enterprise"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But yes, PROC REPORT is pretty neat. I recommend that you start by reading some of the &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1ai2km76blvcvn12ye0q6i3187a.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;Examples from the PROC REPORT SAS Documentation&lt;/A&gt;. They will get you far.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did my code answer answer&amp;nbsp;work for you?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519265#M140624</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T20:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519268#M140626</link>
      <description>&lt;P&gt;unfortunately no!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it changed my input data!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519268#M140626</guid>
      <dc:creator>NazaninSAS</dc:creator>
      <dc:date>2018-12-06T20:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519270#M140628</link>
      <description>&lt;P&gt;If you by input data mean the data set work.si, then no. I promise you that my code did nothing to your input data &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the log if it generated any errors.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519270#M140628</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T20:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519271#M140629</link>
      <description>&lt;P&gt;Have you considered using Macros. Code is untested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Region_=HQ ATLANTIC PACIFIC PRAIRIES ONTARIO QUEBEC;

%let i=1;
%let Region=%scan(&amp;amp;Region_,&amp;amp;i);

%macro gen_report;

%do %until(&amp;amp;Region eq %str());
	proc sql;
		title "Self Identification by Age Group, &amp;amp;Region Region";
		select Band2, count(SI_PRI) as SI_PRI format=comma10., count (PRI)as PRI format=comma10.,

			calculated SI_PRI/calculated PRI "Return rate" format=percent8.1

		from work.Si

		where REGION="&amp;amp;Region"

			title 'Self Identification by Age Group, &amp;amp;Region Region';
		group by Band2

			union all

		select 'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,

			calculated SI_PRI/calculated PRI "Return rate" format=percent8.1

		from work.Si

		where REGION="&amp;amp;Region"

		;
		TITLE;
	Quit;

	%let i=%eval(&amp;amp;i+1);
%let Region=%scan(&amp;amp;Region_,&amp;amp;i);

%end;
%mend;&lt;BR /&gt;&lt;BR /&gt;%gen_report&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519271#M140629</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-06T20:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519275#M140631</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223883"&gt;@NazaninSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried proc tabulate, no luck! and also it was not the good tool. some SAS folks also recommended PROC REPORT. I have to review it!&lt;/P&gt;
&lt;P&gt;I was struggling with PROC report as well! do you know the equivalent to PROC report on Enterprise. sometimes, when I use Enterprise, I can figure out the codes foe SAS base.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best regards,&lt;/P&gt;
&lt;P&gt;Nazanin&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color="#3366ff" size="5"&gt;Large economy sized hint: Provide some example starting data we can use.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point we do not know anything about the structure of your data, which role any of the named variables except Region might play exactly , and since you are using count aggregates we can't even tell if the other variables are character or numeric.&lt;/P&gt;
&lt;P&gt;When you started asking questions on the forum there were some hints about asking good questions and one of them is providing example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any summary / reporting procedure requires knowledge of the data set structure. A statement like "I tried proc tabulate, no luck!&amp;nbsp;" does not describe what went wrong, you don't show the actual code you attempted for tabulate, any log messages if there were errors or data details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And SQL gets very cumbersome for multiple summaries based on differing groups of variables so I tend to use Proc Summary to create such sets. Perhaps something like this (which fails if PRI or SI_PRI are character, which we don't even know yet).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc summary data=work.final;
   class region;
   var si_pri pri;
   output out=work.summary (drop=_freq_) n = ;
run;
data want;
   set work.summary;
   if _type_=0 then Region='Total';
   ReturnRate = si_pri/pri;
   select (region);
      when ("HQ")           order=1;  
      when ("ATLANTIC")     order=2;
      when ("PACIFIC")      order=3;
      when ("PRAIRIES")     order=4;
      when ("ONTARIO")      order=5;
      when ("QUEBEC")       order=6;
      when ("Total")        order=7;
      otherwise;
   end;
   label 
      Region     = "Region"
      ReturnRate = "Return Rate"
      si_pri     = "Completed surveys"
      pri        = "Employees"
   ;
      
run;
proc sort data=want;
   by order;
run;

proc print data=want noobs label;
   var region si_pri pri returnrate;
   format di_pri pri comma9. returnrate percent8.1;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 20:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519275#M140631</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-06T20:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519284#M140636</link>
      <description>&lt;P&gt;As others have indicated DO loops do not work in PROC SQL.&lt;/P&gt;
&lt;P&gt;To repeat a particular set of code N times you have a few options but a macro is usually one of the faster ways. Another is to use BY groups.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an explanation of how to turn your program into a macro step by step. If you follow these steps you're less likely to run into any errors or issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But as others have indicated you should do this differently. I would recommend doing it in one step personally:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as

select Band2, Region, 1 as sort_order, count(SI_PRI) as SI_PRI format=comma10., count (PRI)as PRI format=comma10.,

calculated SI_PRI/calculated PRI "Return rate" format=percent8.1

from work.Si

where REGION in ('HQ', 'ATLANTIC', 'PACIFIC', "PRAIRIES')


group by Band2 , region

union all

select region, 99 as sort_order,  'TOTAL', count(SI_PRI) as SI_PRI, count (PRI)as PRI,

calculated SI_PRI/calculated PRI "Return rate" format=percent8.1

from work.Si, region

where region in ('HQ', 'ATLANTIC', 'PACIFIC', "PRAIRIES')

;



Quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And as others have indicated, using PROC SQL for summary calculations is fine, but PROC REPORT and TABULATE create better reports.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem new at SAS, so I would recommend taking the free e-courses and checking out the how-to tutorials on video.sas.com&lt;/P&gt;
&lt;P&gt;If you need help with a specific topic, such as PROC REPORT, try searching on Lexjansen.com. It has a ton of resources.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your questions also appear a bit scattered. I suspect you know how to program in another language and are trying to bring that into SAS. The guidelines below can help frame the questions better so you get solutions faster that work for you. In general, show what you have, what you want, and what you tried, preferably in that order as well. And last but not least, explain what you're trying to do, don't just put the code out there. If your code is wrong but we don't know what you're trying to do we can't really help you besides say that's not valid. Help us help you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/help/how-to-ask" target="_blank"&gt;https://stackoverflow.com/help/how-to-ask&lt;/A&gt;&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/223883"&gt;@NazaninSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why my code does not go to the loop?&lt;/P&gt;
&lt;P&gt;basically, the code should give me 6 reports (one for each region), but it gives me only one report which is total of all regions.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#ff0000"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; to &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;case&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"HQ"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"ATLANTIC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"PACIFIC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"PRAIRIES"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"ONTARIO"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; REGION=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"QUEBEC"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; as REGION;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2 format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;$8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count(SI_PRI) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, count (PRI)&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;comma10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;group&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Band2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;union&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;all&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;'TOTAL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; , count(SI_PRI) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SI_PRI, count (PRI)&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; PRI,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;calculated SI_PRI/calculated PRI &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"Return rate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; format=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;percent8.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.Si&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;i=i+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Nazanin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 21:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519284#M140636</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-06T21:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519932#M140929</link>
      <description>&lt;P&gt;Thanks a lot Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used Proc Report, and it was so fast and efficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nazanin&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop/m-p/519932#M140929</guid>
      <dc:creator>NazaninSAS</dc:creator>
      <dc:date>2018-12-10T12:39:30Z</dc:date>
    </item>
  </channel>
</rss>

