<?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: Need Help with Summing Distinct in a Database in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150996#M39786</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Point, PG!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: if anyone is interested, PG is saying the above statement is better off replace by the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from (select distinct supplier from have), (select distinct year from have) &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Sep 2014 19:12:28 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2014-09-18T19:12:28Z</dc:date>
    <item>
      <title>Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150990#M39780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had a question for you- I tried to look through to forums to see if something similar has been answered before but couldn't find anything- I apologize if it has! I'm completely new to SAS and have just been figuring things out as I go along and have run into a bit of a road-bump. I've posted the details below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have a dataset that looks like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="234" style="border: 1px solid rgb(0, 0, 0); width: 425px; height: 236px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Customer ID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Supplier&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;12014&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;12014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;22222&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;11111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;41243&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2003&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;11111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;41531&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do is sum the number of unique customers that each supplier has by year, to get a database that looks like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="156" style="border: 1px solid rgb(0, 0, 0); width: 571px; height: 158px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Supplier&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;# of Unique Customers&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2003&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;88888&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2003&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;99999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a customer comes one year and again the next, they would count as unique. If they make multiple purchases in one year, they are not considered unique. I have really no idea how to get from the data I have to the data I want. Any advice would be much appreciated! Thank you. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 17:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150990#M39780</guid>
      <dc:creator>jackie32</dc:creator>
      <dc:date>2014-09-18T17:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150991#M39781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't say if you want a dataset or output. This will create output, prefix with a "create table &amp;lt;name&amp;gt; as" before the first select. "Have" represents the name of your current dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select supplier, year, count(*) as customers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from (select distinct supplier,year, customerid from have)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by supplier, year;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 18:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150991#M39781</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-09-18T18:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150992#M39782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;BR /&gt;input CustomerID Year Supplier;&lt;BR /&gt;datalines;&lt;BR /&gt;12014 2001 88888&lt;BR /&gt;12014 2001 88888&lt;BR /&gt;22222 2002 88888&lt;BR /&gt;11111 2001 99999&lt;BR /&gt;41243 2003 99999&lt;BR /&gt;11111 2004 99999&lt;BR /&gt;41531 2004 88888&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data base;&lt;BR /&gt;do supplier=88888 to 99999 by 11111;&lt;BR /&gt;do year=2001 to 2004;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select a.supplier,a.year,count(distinct b.customerid) as unique_customer from base a&lt;BR /&gt;left join have b&lt;BR /&gt;on a.supplier=b.supplier&lt;BR /&gt;and a.year=b.year&lt;BR /&gt;group by a.supplier,a.year;&lt;BR /&gt;quit; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 18:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150992#M39782</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-09-18T18:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150993#M39783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only problem for solving this with SQL is getting zeros for suppliers/years without data. It can be done this way: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select s.supplier, y.year, coalesce(c.nbCust, 0) as nbCust&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(select distinct supplier from have) as s cross join &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(select distinct year from have) as y left join&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(select supplier, year, count(distinct customerid) as nbCust&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; from have&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; group by supplier, year) as c &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; on s.supplier=c.supplier and y.year=c.year;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 18:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150993#M39783</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-09-18T18:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150994#M39784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, the more, the merrier. Freshly learned from &lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Customer_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Year Supplier;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;12014 2001 88888&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;12014 2001 88888&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;22222 2002 88888&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;11111 2001 99999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;41243 2003 99999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;11111 2004 99999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;41531 2004 88888&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; a.supplier, a.year, count(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; b.customer_id) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ct &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have (keep=supplier) , have (keep=year) ) a&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; natural &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; a.supplier,a.year&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; a.supplier,a.year&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 18:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150994#M39784</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-09-18T18:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150995#M39785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A __default_attr="5068" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;, the crossproduct join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: blue; background: white;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: black; background: white;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: black; background: white;"&gt; have (keep=supplier) , have (keep=year)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;might generate a large table before being shrunk by the distinct clause (unless it is somehow optimized out). I prefer to apply distinct &lt;SPAN style="text-decoration: underline;"&gt;before&lt;/SPAN&gt; doing the crossproduct. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 19:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150995#M39785</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-09-18T19:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150996#M39786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Point, PG!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: if anyone is interested, PG is saying the above statement is better off replace by the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from (select distinct supplier from have), (select distinct year from have) &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 19:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150996#M39786</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-09-18T19:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150997#M39787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've always been a fan of the double proc freq, just because its easy to understand &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=have noprint;&lt;/P&gt;&lt;P&gt;table supplier*year*customer_id/out=temp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=temp noprint;&lt;/P&gt;&lt;P&gt;table supplier*year/out=want sparse;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 19:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150997#M39787</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-09-18T19:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150998#M39788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for sharing, Reeza! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 19:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150998#M39788</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-09-18T19:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Summing Distinct in a Database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150999#M39789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all so much- all your input has been incredibly helpful and I greatly appreciate it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 20:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-with-Summing-Distinct-in-a-Database/m-p/150999#M39789</guid>
      <dc:creator>jackie32</dc:creator>
      <dc:date>2014-09-18T20:11:19Z</dc:date>
    </item>
  </channel>
</rss>

