<?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 Counting unique entries of one variable by a categorical variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-entries-of-one-variable-by-a-categorical/m-p/351869#M81954</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sample dataset with the folliwing variables: ID, Location, and Locationtype. Location type is only 3 categorical entries of 1,2,3. How do I write a code that will count unique values of location for each of the 3 cateogries of locationtype?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample code. Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data JANFEB.SAMPLEUNIQUE;
  infile datalines dsd truncover;
  input ID:BEST. Location:$1. LocationType:BEST.;
datalines4;
1,A,1
2,B,2
3,C,3
4,D,1
5,E,2
6,F,3
7,G,1
8,H,2
9,I,3
10,J,1
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like the output to look something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;LocationType&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Unique Locations&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;23&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;14&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;15&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Thu, 20 Apr 2017 19:17:55 GMT</pubDate>
    <dc:creator>byeh2017</dc:creator>
    <dc:date>2017-04-20T19:17:55Z</dc:date>
    <item>
      <title>Counting unique entries of one variable by a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-entries-of-one-variable-by-a-categorical/m-p/351869#M81954</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sample dataset with the folliwing variables: ID, Location, and Locationtype. Location type is only 3 categorical entries of 1,2,3. How do I write a code that will count unique values of location for each of the 3 cateogries of locationtype?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample code. Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data JANFEB.SAMPLEUNIQUE;
  infile datalines dsd truncover;
  input ID:BEST. Location:$1. LocationType:BEST.;
datalines4;
1,A,1
2,B,2
3,C,3
4,D,1
5,E,2
6,F,3
7,G,1
8,H,2
9,I,3
10,J,1
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like the output to look something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;LocationType&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Unique Locations&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;23&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;14&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;15&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 19:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-entries-of-one-variable-by-a-categorical/m-p/351869#M81954</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-20T19:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique entries of one variable by a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-entries-of-one-variable-by-a-categorical/m-p/351878#M81961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select 
	LocationType,
	count(distinct Location) as uniqueLocations
from JANFEB.SAMPLEUNIQUE
group by LocationType;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 19:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-entries-of-one-variable-by-a-categorical/m-p/351878#M81961</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-20T19:35:37Z</dc:date>
    </item>
  </channel>
</rss>

