<?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 Count based on ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796766#M255695</link>
    <description>&lt;P&gt;Hello everyone, I have a large dataset that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input customerID product;
datalines;
A1 P4
A1 P6
A1 P2
A2 P3
A2 P4
A3 P1
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get a count of how many products each customerID has assigned to it. Each row is unique so there is no need to account for duplicates.&lt;/P&gt;&lt;P&gt;This is what I'm trying to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;

input customerID product count;
datalines;
A1 P4 3
A1 P6 3
A1 P2 3
A2 P3 2
A2 P4 2
A3 P1 1
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 01:40:12 GMT</pubDate>
    <dc:creator>raddad34</dc:creator>
    <dc:date>2022-02-17T01:40:12Z</dc:date>
    <item>
      <title>Count based on ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796766#M255695</link>
      <description>&lt;P&gt;Hello everyone, I have a large dataset that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input customerID product;
datalines;
A1 P4
A1 P6
A1 P2
A2 P3
A2 P4
A3 P1
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get a count of how many products each customerID has assigned to it. Each row is unique so there is no need to account for duplicates.&lt;/P&gt;&lt;P&gt;This is what I'm trying to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;

input customerID product count;
datalines;
A1 P4 3
A1 P6 3
A1 P2 3
A2 P3 2
A2 P4 2
A3 P1 1
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 01:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796766#M255695</guid>
      <dc:creator>raddad34</dc:creator>
      <dc:date>2022-02-17T01:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Count based on ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796771#M255699</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input customerID $ product $;
datalines;
A1 P4
A1 P6
A1 P2
A2 P3
A2 P4
A3 P1
;
run;

proc SQL;
Create table want as
select customerID,
	   product,
	   count(1) as count
from have
group by customerID;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 01:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796771#M255699</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2022-02-17T01:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Count based on ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796776#M255703</link>
      <description>&lt;P&gt;If the data are sorted by customerid:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (in=firstpass) have (in=secondpass);
  by customerid;
  if first.customerid then count=0;
  count + firstpass;
  if secondpass;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 02:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-based-on-ID/m-p/796776#M255703</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-02-17T02:16:00Z</dc:date>
    </item>
  </channel>
</rss>

