<?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: aggregating data by in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189534#M3913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks to Both of you!&lt;/P&gt;&lt;P&gt;It works!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Mar 2015 16:48:39 GMT</pubDate>
    <dc:creator>sarang</dc:creator>
    <dc:date>2015-03-03T16:48:39Z</dc:date>
    <item>
      <title>aggregating data by</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189531#M3910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to aggregate individual purchase data.&lt;/P&gt;&lt;P&gt;The data set contains all information about where, when, and what each individual purchased a product.&lt;/P&gt;&lt;P&gt;It consists of more than 10 columns. &lt;/P&gt;&lt;P&gt;When I used &lt;A&gt; code to aggregate the data, I get only 6 columns (&lt;SPAN style="font-size: 13.3333330154419px;"&gt;id, week, retailer, product_code, quantity, total_price&lt;/SPAN&gt;).&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, I want to keep all other columns as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To keep all columns, I used &lt;B&gt;. I wonder if it is a right approach. Unfortunately, &lt;A&gt; and &lt;B&gt; have different results with different numbers of rows.&lt;/B&gt;&lt;/A&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;How can I solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.Panel_purchase as&lt;/P&gt;&lt;P&gt;select id, week, retailer, product_code, sum(quantity) as quantity, sum(total_price) as total_price&lt;/P&gt;&lt;P&gt;from work.Purchase_all&lt;/P&gt;&lt;P&gt;group by id, week, retailer, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;product_code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;order by id, week, retailer, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;product_code&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.Panel_purchase as&lt;/P&gt;&lt;P&gt;select *, sum(quantity) as quantity, sum(total_price) as total_price&lt;/P&gt;&lt;P&gt;from work.Purchase_all&lt;/P&gt;&lt;P&gt;group by id, week, retailer, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;product_code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;order by id, week, retailer, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;product_code&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc sort data=Work.Panel_purchase out=Work.Panel_purchase nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id week retailer &lt;SPAN style="font-size: 13.3333330154419px;"&gt;product_code&lt;/SPAN&gt; quantity total_price_paid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 06:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189531#M3910</guid>
      <dc:creator>sarang</dc:creator>
      <dc:date>2015-03-03T06:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating data by</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189532#M3911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;List &lt;STRONG&gt;all&lt;/STRONG&gt; your variables (that are &lt;STRONG&gt;not aggregated&lt;/STRONG&gt;) in the group by clause.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table work.Panel_purchase as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select id, week, retailer, product_code, sum(quantity) as quantity, sum(total_price) as total_price&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from work.Purchase_all&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;group by id, week, retailer, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;product_code&lt;STRONG&gt;, id2, month, col3, col4&lt;/STRONG&gt; /*etc...*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;order by id, week, retailer, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;product_code&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 13:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189532#M3911</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-03T13:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating data by</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189533#M3912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the select part, keep all of the variables EXCEPT those that you will summarize, and add the sum() for the variables to be summarized; add all non-summarized variables to the group by part.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 13:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189533#M3912</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-03T13:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating data by</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189534#M3913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks to Both of you!&lt;/P&gt;&lt;P&gt;It works!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 16:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/aggregating-data-by/m-p/189534#M3913</guid>
      <dc:creator>sarang</dc:creator>
      <dc:date>2015-03-03T16:48:39Z</dc:date>
    </item>
  </channel>
</rss>

