<?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: calculate the distinct value in column B over (partition by column A) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/calculate-the-distinct-value-in-column-B-over-partition-by/m-p/814314#M40700</link>
    <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;But you don't need it in SAS.&lt;/P&gt;
&lt;P&gt;Just use your first example with the normal GROUP BY and SAS will remerge the count onto the appropriate values of A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2022 15:38:22 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-05-19T15:38:22Z</dc:date>
    <item>
      <title>calculate the distinct value in column B over (partition by column A)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/calculate-the-distinct-value-in-column-B-over-partition-by/m-p/814304#M40699</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;In SAS EG, is there a way to use the statement count(distinct flob) over (partition by police) as N, like the example for test3 (see code below) and if so, how ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input police $ flob $ Other_info $;
   datalines;
1 A X1
1 B X1
1 C X1
1 D X1
1 E X1
2 A TR
2 C TR
;
RUN;

PROC SQL;
create table test1 as
select *,
		count(distinct flob) as N
from test
group by police;
QUIT;

PROC SQL;
create table test2 as
select *,
		count(distinct flob) over (partition by police) as N
from test;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 14:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/calculate-the-distinct-value-in-column-B-over-partition-by/m-p/814304#M40699</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-05-19T14:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the distinct value in column B over (partition by column A)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/calculate-the-distinct-value-in-column-B-over-partition-by/m-p/814314#M40700</link>
      <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;But you don't need it in SAS.&lt;/P&gt;
&lt;P&gt;Just use your first example with the normal GROUP BY and SAS will remerge the count onto the appropriate values of A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 15:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/calculate-the-distinct-value-in-column-B-over-partition-by/m-p/814314#M40700</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-19T15:38:22Z</dc:date>
    </item>
  </channel>
</rss>

