<?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: Counting the number of IDs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301675#M63885</link>
    <description>&lt;P&gt;Or use a SQL query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table salesCount as
select nSales, count(id) as nIndividuals
from (
    select id, count(sales) as nSales from have group by id)
group by nSales;
select * from salesCount;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Sep 2016 01:59:30 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-09-30T01:59:30Z</dc:date>
    <item>
      <title>Counting the number of IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301637#M63872</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with hundreds of observations. I wanted to know how many individual IDs had more than1 or 2 or 3.... sales. Here is my sample dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;car&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;truck&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;bike&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;plane&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;bike&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;car&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;motor&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;plane&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;bike&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;car&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;motor&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above dataset each Individual ID had either 4 sales (For 1st ID), 3 sales (For 2nd ID) or 4 sales (For 4th ID). I wanted to know how many individuals had 4 sale count and three sale count. My output should look something like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Nsales&lt;/TD&gt;&lt;TD&gt;Nindividuals&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There were no Subject IDs with 1 or 2 sales count. So the first two rows are zero. There was 1 subject ID (ID-2) with 3 sales and 2 subject IDs (ID-1 and 4) with 4 sales.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 20:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301637#M63872</guid>
      <dc:creator>danwarags</dc:creator>
      <dc:date>2016-09-29T20:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301638#M63873</link>
      <description>&lt;P&gt;Double proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. First one gets you a count by Person and Sales (table id).&lt;/P&gt;
&lt;P&gt;2. Second one gets you how many of each types of sales and then you can filter out what you need.&lt;/P&gt;
&lt;P&gt;You won't get 0's though, only missing so you'll need fo find a way to add them in, there's several.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=sashelp.cars noprint;&lt;/P&gt;
&lt;P&gt;table make/out=countID;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=countID;&lt;/P&gt;
&lt;P&gt;table count/out=Want;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 20:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301638#M63873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-29T20:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301675#M63885</link>
      <description>&lt;P&gt;Or use a SQL query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table salesCount as
select nSales, count(id) as nIndividuals
from (
    select id, count(sales) as nSales from have group by id)
group by nSales;
select * from salesCount;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2016 01:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-IDs/m-p/301675#M63885</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-30T01:59:30Z</dc:date>
    </item>
  </channel>
</rss>

