<?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: Unique or Distinct value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583953#M166274</link>
    <description>&lt;P&gt;Example input data and the desired output for that data goes a long ways to avoiding multiple questions about this case, that case and what was intended.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2019 15:23:39 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-08-26T15:23:39Z</dc:date>
    <item>
      <title>Unique or Distinct value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583802#M166229</link>
      <description>&lt;P&gt;I'm trying to return a value of 1 for each unique occurrence of Ref_numb&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried the below and I'm getting a result, but my unique customer count is 18 less than what I'm expecting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something I'm missing with the code below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sort data=work.testdata ;
  by Ref_Numb;
run;


data work.test_Op ;
  set work.testdata ;
  by Ref_Numb ; 
  if first.Ref_Numb then UniqCustomer = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Aug 2019 01:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583802#M166229</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2019-08-26T01:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unique or Distinct value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583811#M166235</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/41546"&gt;@Haydn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want 1 for each distinct ID? Then how to count the number of distinct values? I show a simple example and see whether it helps you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id x;
datalines;
10 23
10 12
10 11
20 30
20 40
30 12
;
run;
proc sort data = have;
by id;
run;

data want;
   set have;
   by id;
   if first.id then uniqC + 1;
   put uniqC =;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Aug 2019 03:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583811#M166235</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-26T03:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unique or Distinct value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583815#M166237</link>
      <description>&lt;P&gt;Do you simply want a value of 1 on the first occurrence of a customer? If so,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Ref_Numb num;
datalines;
2 1
1 4
2 2
1 3
3 6
1 5
;

data want;
	if _N_=1 then do;
		declare hash h();
		h.definekey('Ref_Numb');
		h.definedone();
	end;

	set have;

	if h.check() ne 0 then do;
		UniqCustomer=1;
		h.add();
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Aug 2019 05:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583815#M166237</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-26T05:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Unique or Distinct value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583953#M166274</link>
      <description>&lt;P&gt;Example input data and the desired output for that data goes a long ways to avoiding multiple questions about this case, that case and what was intended.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-or-Distinct-value/m-p/583953#M166274</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-26T15:23:39Z</dc:date>
    </item>
  </channel>
</rss>

