<?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: Grouping in Proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143058#M38053</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help- that worked. However I have a dataset with 100000+ observations with multiple policy providers hence i need a count of total policies sold by respective companies so that i could know which has the highest market cap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Oct 2014 14:29:36 GMT</pubDate>
    <dc:creator>Shivi82</dc:creator>
    <dc:date>2014-10-27T14:29:36Z</dc:date>
    <item>
      <title>Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143056#M38051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I am working on a data set where i need to group the data basis product type. However i am unable to do so. I have written 2 codes below.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table ttt as&lt;/P&gt;&lt;P&gt;select product, count (*) as total category, age, income&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;from sss.sales;&lt;/P&gt;&lt;P&gt;group by product&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table ttt as&lt;/P&gt;&lt;P&gt;select count (product) as new, category, age, income&lt;/P&gt;&lt;P&gt;from sss.sales;&lt;/P&gt;&lt;P&gt;group by product&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However with both the programmes i am unable to find total values for each product type. Product type here is policies such as AIG, Metlife etc. Kindly advice. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 13:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143056#M38051</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2014-10-27T13:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143057#M38052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have a semi-colon after 'from sss.sales' which shouldn't be there. Rather, the semi-colon should be after group by product.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 14:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143057#M38052</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-10-27T14:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143058#M38053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help- that worked. However I have a dataset with 100000+ observations with multiple policy providers hence i need a count of total policies sold by respective companies so that i could know which has the highest market cap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 14:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143058#M38053</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2014-10-27T14:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143059#M38054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table ttt as&lt;/P&gt;&lt;P&gt;select product,count (product) as total_category&lt;/P&gt;&lt;P&gt;from sss.sales&lt;/P&gt;&lt;P&gt;group by product;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 15:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143059#M38054</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-27T15:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143060#M38055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to be a bit clearer regarding what you want to achieve. There was another problem with your code, but one can't address is without knowing more: is the new count variable supposed to be called total_category, or just total, and category being another variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, what do you want to do with category, age and income? As is, it will give you the totals, but also provide a record for each record in your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are two versions that work, but may not provide what you are looking to accomplish:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table ttt1 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select product, count (*) as total, category, age, income&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sss.sales&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by product&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table ttt2 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select product, count (*) as total&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sss.sales&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by product&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 15:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143060#M38055</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-10-27T15:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143061#M38056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a great deal Arthur and stat@sas. Both the replies worked for me. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 15:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-in-Proc-SQL/m-p/143061#M38056</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2014-10-27T15:19:22Z</dc:date>
    </item>
  </channel>
</rss>

