<?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 Coding for Average (Mean) among parts of column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228843#M267946</link>
    <description>&lt;P&gt;Hi Ruslan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your email. greatly appreciated. I would like to ask further question - how do I specify the line&lt;/P&gt;
&lt;P&gt;%let vars = store_1 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As currently I have 276 stores?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to shortform that? Like using array {*}? Is that possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2015 12:18:30 GMT</pubDate>
    <dc:creator>DavidLie</dc:creator>
    <dc:date>2015-10-07T12:18:30Z</dc:date>
    <item>
      <title>SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228809#M267944</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am in my final stage of getting my dataset ready. I just need to do one last thing and I hope the SAS community can help me to do in the fastest way as I have approximately 1 million obsevation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I have:&lt;/P&gt;
&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="320"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="5" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt; width: 48pt;" height="20" width="64"&gt;Product&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Week&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Store 1&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Store 2&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Store 3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;44&lt;/TD&gt;
&lt;TD align="right"&gt;88&lt;/TD&gt;
&lt;TD align="right"&gt;68&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;57&lt;/TD&gt;
&lt;TD align="right"&gt;65&lt;/TD&gt;
&lt;TD align="right"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;35&lt;/TD&gt;
&lt;TD align="right"&gt;37&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;48&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;58&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;81&lt;/TD&gt;
&lt;TD align="right"&gt;9&lt;/TD&gt;
&lt;TD align="right"&gt;39&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;19&lt;/TD&gt;
&lt;TD align="right"&gt;17&lt;/TD&gt;
&lt;TD align="right"&gt;13&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This data contains product (labelled 1, 2, 3, etc.); week (week identifier from 1 to 52); and store earning (store 1 to 276).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do I want to achieve?&lt;/P&gt;
&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="256"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="4" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt; width: 48pt;" height="20" width="64"&gt;Product&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Week&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Store&lt;/TD&gt;
&lt;TD style="width: 48pt;" width="64"&gt;Average&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;34.66667&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;62.66667&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;39.66667&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;49.33333&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;42&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD style="height: 15.0pt;" align="right" height="20"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;
&lt;P&gt;36.66667&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to take the average earnings from each store by product and week. For example, the first row (i.e., Product 1, Week 1, Store 1 - the average is calculated based on the average of 44, 57 and 3, and that is 34.67).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone lend me a hand on this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;David&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 10:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228809#M267944</guid>
      <dc:creator>DavidLie</dc:creator>
      <dc:date>2015-10-07T10:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228812#M267945</link>
      <description>&lt;P&gt;Here you go!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; have;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input&lt;/SPAN&gt; Product Week Store_1 Store_2 Store_3 ;&lt;/P&gt;
&lt;P&gt;datalines&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 1 44 88 68&lt;/P&gt;
&lt;P&gt;1 1 57 65 14&lt;/P&gt;
&lt;P&gt;1 1 3 35 37&lt;/P&gt;
&lt;P&gt;1 2 48 100 58&lt;/P&gt;
&lt;P&gt;1 2 81 9 39&lt;/P&gt;
&lt;P&gt;1 2 19 17 13&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let&lt;/SPAN&gt; vars = Store_1 Store_2 Store_3;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;means&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=have &lt;SPAN&gt;noprint&lt;/SPAN&gt;;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;by&lt;/SPAN&gt; Product Week;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &amp;amp;vars;&lt;/P&gt;
&lt;P&gt;output out&lt;SPAN&gt;=want &lt;/SPAN&gt;mean&lt;SPAN&gt;=;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 11:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228812#M267945</guid>
      <dc:creator>Ruslan</dc:creator>
      <dc:date>2015-10-07T11:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228843#M267946</link>
      <description>&lt;P&gt;Hi Ruslan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your email. greatly appreciated. I would like to ask further question - how do I specify the line&lt;/P&gt;
&lt;P&gt;%let vars = store_1 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As currently I have 276 stores?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to shortform that? Like using array {*}? Is that possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 12:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228843#M267946</guid>
      <dc:creator>DavidLie</dc:creator>
      <dc:date>2015-10-07T12:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228849#M267947</link>
      <description>&lt;P&gt;Well, the only way I can think about is to&amp;nbsp;create&amp;nbsp;the list of Store_1, Store_2 until Store_276 in excel and then put the entire list to %vars = Store_1 Store_2 Store_3 ... Store_276. let me know if this works for you&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 12:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228849#M267947</guid>
      <dc:creator>Ruslan</dc:creator>
      <dc:date>2015-10-07T12:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228853#M267948</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your reponse to the suggestion shows exactly why your data is setup incorrectly. &amp;nbsp;I always recommend to have a normalised table, this is where the data goes down, rather than across. &amp;nbsp;It is far easier to do by group processing if the data is normalised.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input Product Week Store_1 Store_2 Store_3 ;
datalines;
1 1 44 88 68
1 1 57 65 14
1 1 3 35 37
1 2 48 100 58
1 2 81 9 39
1 2 19 17 13
;
run;
data normalised (drop=store_:);
  set have;
  array store_{3};
  do store=1 to dim(store_);
    result=store_{store};
    output;
  end;
run;
proc means data=have noprint;       
  by Product Week store;   
  var result;
  output out=want mean=;   
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Oct 2015 12:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228853#M267948</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-07T12:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding for Average (Mean) among parts of column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228878#M267949</link>
      <description>&lt;P&gt;data table;&lt;BR /&gt;infile cards;&lt;BR /&gt;input Product$ &amp;nbsp;&amp;nbsp; &amp;nbsp;Week &amp;nbsp;&amp;nbsp; &amp;nbsp;Store_1 &amp;nbsp;&amp;nbsp; &amp;nbsp;Store_2 &amp;nbsp;&amp;nbsp; &amp;nbsp;Store_3;&lt;BR /&gt;cards;&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;44 &amp;nbsp;&amp;nbsp; &amp;nbsp;88 &amp;nbsp;&amp;nbsp; &amp;nbsp;68&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;57 &amp;nbsp;&amp;nbsp; &amp;nbsp;65 &amp;nbsp;&amp;nbsp; &amp;nbsp;14&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;3 &amp;nbsp;&amp;nbsp; &amp;nbsp;35 &amp;nbsp;&amp;nbsp; &amp;nbsp;37&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;2 &amp;nbsp;&amp;nbsp; &amp;nbsp;48 &amp;nbsp;&amp;nbsp; &amp;nbsp;100 58&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;2 &amp;nbsp;&amp;nbsp; &amp;nbsp;81 &amp;nbsp;&amp;nbsp; &amp;nbsp;9 &amp;nbsp;&amp;nbsp; &amp;nbsp;39&lt;BR /&gt;1 &amp;nbsp;&amp;nbsp; &amp;nbsp;2 &amp;nbsp;&amp;nbsp; &amp;nbsp;19 &amp;nbsp;&amp;nbsp; &amp;nbsp;17 &amp;nbsp;&amp;nbsp; &amp;nbsp;13&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;proc summary data=table;&lt;BR /&gt;var store:;&lt;BR /&gt;by product week;&lt;BR /&gt;output out=want(drop=_type_ _freq_) mean=;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 13:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding-for-Average-Mean-among-parts-of-column/m-p/228878#M267949</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-07T13:48:19Z</dc:date>
    </item>
  </channel>
</rss>

