<?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: New to SAS - How to add up values for the same item? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548348#M8505</link>
    <description>&lt;P&gt;Thanks for the insight! It was the "group by" statement I was looking for. (Y)&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2019 21:14:55 GMT</pubDate>
    <dc:creator>12we</dc:creator>
    <dc:date>2019-04-03T21:14:55Z</dc:date>
    <item>
      <title>New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548296#M8498</link>
      <description>&lt;P&gt;Hello there, I'm new to SAS and was wondering if someone can help me with this simple question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to sort the data but I'm wondering how a to add up all the values for each store instead of each sales showing up like this one for example?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Store_no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales&lt;/P&gt;&lt;P&gt;store1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$10&lt;/P&gt;&lt;P&gt;store1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$5&lt;/P&gt;&lt;P&gt;store2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$12&lt;/P&gt;&lt;P&gt;store2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$1&lt;/P&gt;&lt;P&gt;store2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$100&lt;/P&gt;&lt;P&gt;store3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$50&lt;/P&gt;&lt;P&gt;store4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$0&lt;/P&gt;&lt;P&gt;store4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a bunch!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 18:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548296#M8498</guid>
      <dc:creator>12we</dc:creator>
      <dc:date>2019-04-03T18:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548297#M8499</link>
      <description>&lt;P&gt;do you mean you want a sum(sales) i.e&amp;nbsp; 194 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;sum(sales)&amp;nbsp; within&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;group by storeno&amp;nbsp;&lt;/EM&gt; &lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 18:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548297#M8499</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-03T18:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548299#M8500</link>
      <description>&lt;P&gt;Hi, thanks for getting back, that was so fast!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the sum of sales for each store number so that only one store number obs will show up. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Store_no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales&lt;/P&gt;&lt;P&gt;store1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$15&lt;/P&gt;&lt;P&gt;store2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$113&lt;/P&gt;&lt;P&gt;store3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$50&lt;/P&gt;&lt;P&gt;store4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 18:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548299#M8500</guid>
      <dc:creator>12we</dc:creator>
      <dc:date>2019-04-03T18:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548300#M8501</link>
      <description>&lt;P&gt;if you like proc sql&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table want as

select storeno, sum(sales) as tot_sales

from your_have

group by storeno

order by storeno;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 18:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548300#M8501</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-03T18:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548348#M8505</link>
      <description>&lt;P&gt;Thanks for the insight! It was the "group by" statement I was looking for. (Y)&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548348#M8505</guid>
      <dc:creator>12we</dc:creator>
      <dc:date>2019-04-03T21:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548424#M8513</link>
      <description>&lt;P&gt;As always, there are multiple ways to achieve the same result.&lt;/P&gt;
&lt;P&gt;(example data)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Store_no $ Sales :dollar10.;
format sales dollar10.;
datalines;
store1 $10
store1 $5
store2 $12
store2 $1
store2 $100
store3 $50
store4 $0
store4 $16
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In addition to the SQL method, there's&lt;/P&gt;
&lt;P&gt;a data step that does it "manually":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want1;
set have;
by store_no;
retain tot_sales;
format tot_sales dollar10.;
if first.store_no
then tot_sales = sales;
else tot_sales + sales;
if last.store_no then output;
drop sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(needs sort by store_no)&lt;/P&gt;
&lt;P&gt;or proc summary:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class store_no;
var sales;
output
  out=want2 (drop=_type_ _freq_)
  sum(sales)=tot_sales
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 07:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548424#M8513</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-04T07:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS - How to add up values for the same item?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548527#M8546</link>
      <description>&lt;P&gt;One question to ask yourself when doing summaries: Do I need a data set for further processing or is the summary a report that people will read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If people are using the information, an indication being currency symbol, then perhaps one of the report procedures such as Proc Report or Tabulate might be in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data=have ;
   columns Store_no sales;
   define Store_no /group;
   define sales/ analysis;
run;&lt;/PRE&gt;
&lt;P&gt;If a report is in order then you may find that a simple to moderately complex layout may be easy enough to do in a single step&amp;nbsp;as you may still need to do stuff to display your data set later.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/New-to-SAS-How-to-add-up-values-for-the-same-item/m-p/548527#M8546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-04T14:57:57Z</dc:date>
    </item>
  </channel>
</rss>

