<?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: How to count distinct values of a Character type field in a SAS dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267186#M52779</link>
    <description>&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;Could you please give a small example for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2016 10:14:07 GMT</pubDate>
    <dc:creator>PoojaP1</dc:creator>
    <dc:date>2016-04-29T10:14:07Z</dc:date>
    <item>
      <title>How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267182#M52776</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help, on how to count distinct values for a character type field in a SAS dataset? Like, I have a field of email addresses in a dataset, and I want to count the distinct email addresses only. I could get the desired results using PROC SQL, but I wanted to know if there is any other way to do the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 09:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267182#M52776</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-04-29T09:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267185#M52778</link>
      <description>&lt;P&gt;There are, as always many ways to acheive the result.&lt;/P&gt;
&lt;P&gt;Proc SQL - as you mention&lt;/P&gt;
&lt;P&gt;Data step, count each row.&lt;/P&gt;
&lt;P&gt;Proc means:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/240-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/240-29.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Proc freq:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect006.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect006.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Proc summary:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473735.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473735.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 10:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267185#M52778</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-29T10:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267186#M52779</link>
      <description>&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;Could you please give a small example for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 10:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267186#M52779</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-04-29T10:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267189#M52780</link>
      <description>&lt;P&gt;With the help of the links provided, try to use them. If you run into obstacles, then get back to us.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 10:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267189#M52780</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-04-29T10:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267193#M52783</link>
      <description>&lt;P&gt;Proc means- does not give any results for Character type variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc freq- I did not get the desired output. Like, I have a field of email address in the dataset, using proc freq displayed all email addresses with count as 1 in front of each.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc summary- I have never used, I am trying and it runs into errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 10:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267193#M52783</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-04-29T10:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267196#M52785</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83215"&gt;@PoojaP1﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SORT with NODUPKEY and OUT= options would be another method (in addition to the approaches listed by RW9).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that some approaches differ in how missing values (and special missing values) are handled. For example, a COUNT(DISTINCT ...) in PROC SQL excludes missing values, whereas one missing value (of each kind in case of special missing values), if any, would remain after a NODUPKEY sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The optimal method will depend on the number of observations in the dataset, the expected number of distinct values and other considerations, e.g., whether the dataset is already sorted by that character variable.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 10:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267196#M52785</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-29T10:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267230#M52788</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another technique is using Hash tables and&amp;nbsp;SUMINC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Let Hash SUMINC Count For You" href="http://www.pharmasug.org/proceedings/2014/CC/PharmaSUG-2014-CC02.pdf" target="_blank"&gt;http://www.pharmasug.org/proceedings/2014/CC/PharmaSUG-2014-CC02.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 14:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267230#M52788</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2016-04-29T14:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to count distinct values of a Character type field in a SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267381#M52844</link>
      <description>&lt;PRE&gt;
1)

proc freq data=sashelp.class nlevels;
 table sex;
run;



&lt;/PRE&gt;
2)

data _null_;
if 0 then set sashelp.class;
declare hash h(dataset:'sashelp.class');
h.definekey('sex');
h.definedone();

nlevels=h.num_items;
putlog "NOTE:" nlevels;
stop;
run;</description>
      <pubDate>Sat, 30 Apr 2016 04:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-distinct-values-of-a-Character-type-field-in-a-SAS/m-p/267381#M52844</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-30T04:17:36Z</dc:date>
    </item>
  </channel>
</rss>

