<?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: SAS array addition // FOR EACH? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368286#M87821</link>
    <description>&lt;P&gt;Why would you want to use an array?&lt;/P&gt;
&lt;P&gt;To get the total sales just use PROC SUMMARY.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway ;
  class shop;
  var sales ;
  output out=want sum=total_sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Jun 2017 12:51:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-06-19T12:51:07Z</dc:date>
    <item>
      <title>SAS array addition // FOR EACH?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368278#M87816</link>
      <description>&lt;P&gt;I'm putting together a dataset using arrays created from another dataset. Lets say the dataset is as follows:&lt;/P&gt;&lt;PRE&gt;input shop year sales;&lt;BR /&gt;datalines;&lt;BR /&gt;01 01 20000&lt;BR /&gt;01 02 23500&lt;BR /&gt;01 03 21020&lt;BR /&gt;02 01 23664&lt;BR /&gt;02 02 15420&lt;BR /&gt;02 03 14200&lt;BR /&gt;03 01 25623&lt;BR /&gt;03 02 12500&lt;BR /&gt;03 03 20030&lt;BR /&gt;;&lt;BR /&gt;run; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;I want to get the total sales for each shop using an array.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368278#M87816</guid>
      <dc:creator>buffalol</dc:creator>
      <dc:date>2017-06-19T12:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array addition // FOR EACH?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368281#M87818</link>
      <description>&lt;P&gt;Why do you want to use an array to do this? You can do it like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input shop year sales;
datalines;
01 01 20000
01 02 23500
01 03 21020
02 01 23664
02 02 15420
02 03 14200
03 01 25623
03 02 12500
03 03 20030
;

proc sort data = have;
	by shop;
run;

data want(keep = shop total);
	set have;
	by shop;
	if first.shop then total = 0;
	total + sales;
	if last.shop then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368281#M87818</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-19T12:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array addition // FOR EACH?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368286#M87821</link>
      <description>&lt;P&gt;Why would you want to use an array?&lt;/P&gt;
&lt;P&gt;To get the total sales just use PROC SUMMARY.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway ;
  class shop;
  var sales ;
  output out=want sum=total_sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368286#M87821</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-19T12:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array addition // FOR EACH?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368292#M87822</link>
      <description>&lt;P&gt;Look at proc means or summary with a by line for shop. &amp;nbsp;This is the purpose of such procedures:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/240-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/240-29.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;proc means data=have;
  by shop;
  var sales;
  output out=want sum=sum;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368292#M87822</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-19T12:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array addition // FOR EACH?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368316#M87829</link>
      <description>&lt;P&gt;As others have implied an Array is not the correct method for solving this problem. In SAS, an Array is used on a single row, typically, not across multiple rows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can summarize data using a summary PROC, PROC SQL, or a data step using FIRST/LAST.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 13:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-array-addition-FOR-EACH/m-p/368316#M87829</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T13:28:39Z</dc:date>
    </item>
  </channel>
</rss>

