<?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 Grouping data in order to count frequencies in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50080#M10444</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am relatively new to using SAS beyond the routine PROC proceedures.&lt;BR /&gt;
&lt;BR /&gt;
I am trying to create a simple frequency distribution chart, but on grouped data. &lt;BR /&gt;
In other words, I want to define 10 groups, say 0-10, 10-20, ..... 90-100  &lt;BR /&gt;
and then count how many of the originial observations are in each of these 10 groups.&lt;BR /&gt;
Is there an easy way to do this using PROC UNIVARIATE or such?</description>
    <pubDate>Mon, 29 Jun 2009 18:44:49 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-06-29T18:44:49Z</dc:date>
    <item>
      <title>Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50080#M10444</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am relatively new to using SAS beyond the routine PROC proceedures.&lt;BR /&gt;
&lt;BR /&gt;
I am trying to create a simple frequency distribution chart, but on grouped data. &lt;BR /&gt;
In other words, I want to define 10 groups, say 0-10, 10-20, ..... 90-100  &lt;BR /&gt;
and then count how many of the originial observations are in each of these 10 groups.&lt;BR /&gt;
Is there an easy way to do this using PROC UNIVARIATE or such?</description>
      <pubDate>Mon, 29 Jun 2009 18:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50080#M10444</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-29T18:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50081#M10445</link>
      <description>The easiest way is to create a FORMAT (see PROC FORMAT for syntax) and then use PROC FREQ to get your frequencies.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Mon, 29 Jun 2009 22:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50081#M10445</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-06-29T22:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50082#M10446</link>
      <description>Doc's suggestion (PROC FORMAT+PROC FREQ) is just right.&lt;BR /&gt;
&lt;BR /&gt;
More solutions are available, but all very similar, and all within a two pass execution.&lt;BR /&gt;
&lt;BR /&gt;
Another one, would be two SQL queries or one SQL query with sub-query, (which is still a two pass solution), with the inner query producing some temporary GROUP_ID for each row (say GROUP_ID=1 case when 0-10, GROUP_ID=2 case when 10-20, ...), and the outer query counting row for each GROUP_ID.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Tue, 30 Jun 2009 08:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50082#M10446</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-06-30T08:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50083#M10447</link>
      <description>I am surprised SAS has not incoporated an easier way to do this.&lt;BR /&gt;
&lt;BR /&gt;
...... are you all enjoying you legal drugs in Protugal.... just kidding. Wouldn't make a difference to me, but it makes sense economically.</description>
      <pubDate>Tue, 30 Jun 2009 12:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50083#M10447</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-30T12:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50084#M10448</link>
      <description>.... does anybody know of an explicit (simple) example where this is done. I am not familiar with the SQL syntax or even the FORMAT syntax.&lt;BR /&gt;
&lt;BR /&gt;
....... it's no big deal, but I would like to learn it in case I come across it again.</description>
      <pubDate>Tue, 30 Jun 2009 12:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50084#M10448</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-30T12:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50085#M10449</link>
      <description>But, it is indeed an easy procedure.&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select GROUP_ID, count(*) as COUNT from (&lt;BR /&gt;
select int(VALUE/10) as GROUP_ID from INPUT&lt;BR /&gt;
) group by GROUP_ID;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
int(VALUE/10) will return the integer value of VALUE/10, so&lt;BR /&gt;
0 =&amp;lt; VALUE &amp;lt; 10 =&amp;gt; GROUP_ID = 0&lt;BR /&gt;
10 =&amp;lt; VALUE &amp;lt; 20 =&amp;gt; GROUP_ID = 1&lt;BR /&gt;
etc...&lt;BR /&gt;
&lt;BR /&gt;
And by the way, drugs are still pretty illegal here.&lt;BR /&gt;
It was discussed some time ago, but it was a no go idea.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Tue, 30 Jun 2009 13:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50085#M10449</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-06-30T13:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping data in order to count frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50086#M10450</link>
      <description>Wow, that's awesome.&lt;BR /&gt;
&lt;BR /&gt;
I thought I heard on NPR that they decriminalized all drugs in Protugal???</description>
      <pubDate>Tue, 30 Jun 2009 20:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-data-in-order-to-count-frequencies/m-p/50086#M10450</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-30T20:58:10Z</dc:date>
    </item>
  </channel>
</rss>

