<?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: use sql distinct count a*b in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687680#M208783</link>
    <description>&lt;P&gt;If you create two temporary tables consisting of one with just A and the other with Just B, then join them to get the Cartesian product (no where clause or INNER JOIN) and then do a SELECT COUNT DISTINCT on the Cartesian product, I think that should give you the number you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some thing like this but check my syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

&amp;nbsp; CREATE TABLE A_TAB as SELECT DISTINCT A FROM Source_Table;

&amp;nbsp; CREATE TABLE B_TAB as SELECT DISTINCT B FROM Source_Table;

&amp;nbsp; CREATE TABLE A_B_TAB as SELECT * FROM A_TAB, B_TAB;

&amp;nbsp; SELECT COUNT(DISTINCT *) FROM A_B_TAB;

QUIT;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:40:38 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-09-29T23:40:38Z</dc:date>
    <item>
      <title>use sql distinct count a*b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687679#M208782</link>
      <description>&lt;P&gt;I know if i want to find how many distinct a, I can use count (distinct a)&lt;/P&gt;&lt;P&gt;Now I need find how many different combination of a and b.&lt;/P&gt;&lt;P&gt;What I should do?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687679#M208782</guid>
      <dc:creator>walterwang</dc:creator>
      <dc:date>2020-09-29T23:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: use sql distinct count a*b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687680#M208783</link>
      <description>&lt;P&gt;If you create two temporary tables consisting of one with just A and the other with Just B, then join them to get the Cartesian product (no where clause or INNER JOIN) and then do a SELECT COUNT DISTINCT on the Cartesian product, I think that should give you the number you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some thing like this but check my syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

&amp;nbsp; CREATE TABLE A_TAB as SELECT DISTINCT A FROM Source_Table;

&amp;nbsp; CREATE TABLE B_TAB as SELECT DISTINCT B FROM Source_Table;

&amp;nbsp; CREATE TABLE A_B_TAB as SELECT * FROM A_TAB, B_TAB;

&amp;nbsp; SELECT COUNT(DISTINCT *) FROM A_B_TAB;

QUIT;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687680#M208783</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-29T23:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: use sql distinct count a*b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687681#M208784</link>
      <description>&lt;PRE&gt;&amp;nbsp;select count(*) from (select distinct a, b from HAVE) ;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687681#M208784</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-29T23:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: use sql distinct count a*b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687685#M208786</link>
      <description>&lt;P&gt;Another option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  select count(distinct catx('.',sex,age) ) as n_sex_by_age from have ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-sql-distinct-count-a-b/m-p/687685#M208786</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-30T00:00:57Z</dc:date>
    </item>
  </channel>
</rss>

