<?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 do loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312395#M67762</link>
    <description>&lt;P&gt;Hi, I have Amt field and I want to group it in 100's increments and get the field amt_grp. I could do it using If statements like below but I would like to have a more efficient way like do loops or something to code it. Because I have data spreading upto $100,000 I cannot write if statements 1000 times. Please help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if amt &amp;lt; 100 then amt_grp = '&amp;gt; 0';&lt;/P&gt;
&lt;P&gt;else if amt &amp;lt; 200 &amp;nbsp;then amt_grp = '&amp;gt; 100';&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;else if amt &amp;lt; 50000 then amt_grp = '&amp;gt;50000';&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;Amt&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;Amt_grp&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$834.19&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$202.85&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$342.70&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$790.16&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 700&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$51.03&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$129.55&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$65.84&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$79.98&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$148.38&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$825.92&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$551.32&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$59.88&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$319.29&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$112.70&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$666.60&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$306.12&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$1,025.51&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$145.44&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$58.08&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$616.79&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$152.51&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Thu, 17 Nov 2016 17:10:30 GMT</pubDate>
    <dc:creator>helloSAS</dc:creator>
    <dc:date>2016-11-17T17:10:30Z</dc:date>
    <item>
      <title>do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312395#M67762</link>
      <description>&lt;P&gt;Hi, I have Amt field and I want to group it in 100's increments and get the field amt_grp. I could do it using If statements like below but I would like to have a more efficient way like do loops or something to code it. Because I have data spreading upto $100,000 I cannot write if statements 1000 times. Please help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if amt &amp;lt; 100 then amt_grp = '&amp;gt; 0';&lt;/P&gt;
&lt;P&gt;else if amt &amp;lt; 200 &amp;nbsp;then amt_grp = '&amp;gt; 100';&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;else if amt &amp;lt; 50000 then amt_grp = '&amp;gt;50000';&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;Amt&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;Amt_grp&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$834.19&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$202.85&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$342.70&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$790.16&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 700&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$51.03&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$129.55&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$65.84&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$79.98&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$148.38&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$825.92&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$551.32&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$59.88&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$319.29&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$112.70&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$666.60&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$306.12&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$1,025.51&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$145.44&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$58.08&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$616.79&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;$152.51&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&amp;gt; 100&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 17:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312395#M67762</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2016-11-17T17:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312397#M67763</link>
      <description>&lt;P&gt;You can do this by simple use of division and rounding:&lt;/P&gt;
&lt;PRE&gt;data want;
  input amt;
  amt_group=cat("&amp;gt; ",strip(put(floor(amt/100)*100,best.)));
datalines;
834.19
202.85
;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 17:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312397#M67763</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-17T17:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312407#M67767</link>
      <description>&lt;P&gt;In a pedantic mode, since 800 is also &amp;gt; 200 the single &amp;gt; (value) is missleading as your label. Better would be to indicate a range:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input amt;
  amt_group=catx(" - ",floor(amt/100)*100, (1+floor(amt/100))*100-1 );
datalines;
834.19
202.85
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 17:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312407#M67767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-17T17:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312408#M67768</link>
      <description>&lt;P&gt;Alternative way is to use formats, then you can define different formats to gather into different groups size :&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;value &lt;STRONG&gt;grp100f&lt;/STRONG&gt; &amp;nbsp; &amp;nbsp;/* format name must end with a letter */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 - 100 = '&amp;lt;= 100'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;100 - 200 = '&amp;lt;= 200'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;200 - 300 = '&amp;lt;= 300'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;800 - 900 = '&amp;lt;= 800'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;900 -1000 = '&amp;lt;=1000'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; other = '&amp;gt; 1000'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;input amt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; amt_group = put(amt, &lt;STRONG&gt;grp100f.&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 18:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312408#M67768</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-17T18:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312409#M67769</link>
      <description>&lt;P&gt;One way is to create a format. &amp;nbsp;Because PROC FORMAT can use a SAS data set as input, it wouldn't take a long program. &amp;nbsp;One assumption I'm building in here is that your amounts only go to two decimal places. &amp;nbsp;(It could still be done if there are more decimal places, but it takes a slightly more complex program.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data groups;&lt;/P&gt;
&lt;P&gt;length label $ 8;&lt;/P&gt;
&lt;P&gt;do start=0 to 100000 by 100;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end = start + 99.99;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;label = '&amp;gt; ' || left(put(start, 6.));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;retain fmtname 'amtgroup';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you a SAS data set with all the categories defined, in a form that PROC FORMAT can use. &amp;nbsp;Next, create the format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format cntlin=groups;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally use it. &amp;nbsp;You could add this in either a DATA step or any procedure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format amt amtgroup.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could create the character variable you originally asked for in a DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;amt_grp = put(amt, amtgroup.);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested code so it may need to be tweaked. &amp;nbsp;But it should be at least 98% of the way there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that your original code kept 100 exactly in the "&amp;gt; 100" category so I continued that approach here.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 18:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops/m-p/312409#M67769</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-11-17T18:05:48Z</dc:date>
    </item>
  </channel>
</rss>

