<?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 creating mean variable by groups in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/creating-mean-variable-by-groups/m-p/55315#M15403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; SQL with a GROUP BY that is remerging the statistic with the original query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select group, var1, mean(var1) as var2&lt;/P&gt;&lt;P&gt;from table1&lt;/P&gt;&lt;P&gt;group by group;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Feb 2012 08:06:14 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2012-02-16T08:06:14Z</dc:date>
    <item>
      <title>creating mean variable by groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-mean-variable-by-groups/m-p/55314#M15402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I apologize in advance if this question is silly, but how do I create a mean variable by groups. Take the below table for example, I want to calculate a Var2 such that for the first 3 observations, Var2 is the mean(Var1 of the first 3 obs), and Var2 for the next 7 obs is mean(Var1 from id=4 to id=10). ie, to get from Table 1 to Table 2. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 144pt;" width="192"&gt;&lt;TBODY&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt; width: 48pt;" width="64"&gt;Table 1&lt;/TD&gt;&lt;TD style="width: 48pt;" width="64"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD style="width: 48pt;" width="64"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;ID&lt;/TD&gt;&lt;TD class="xl65"&gt;Group&lt;/TD&gt;&lt;TD class="xl65"&gt;Var1&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;4&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;5&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;6&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;7&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;8&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;9&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;10&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 192pt;" width="256"&gt;&lt;TBODY&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt; width: 48pt;" width="64"&gt;Table 2&lt;/TD&gt;&lt;TD style="width: 48pt;" width="64"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD style="width: 48pt;" width="64"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD style="width: 48pt;" width="64"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;ID&lt;/TD&gt;&lt;TD class="xl65"&gt;Group&lt;/TD&gt;&lt;TD class="xl65"&gt;Var1&lt;/TD&gt;&lt;TD class="xl65"&gt;Var2&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;4&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;5&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;6&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;7&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;8&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;9&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt;"&gt;10&lt;/TD&gt;&lt;TD class="xl65"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;10&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 07:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-mean-variable-by-groups/m-p/55314#M15402</guid>
      <dc:creator>leonh</dc:creator>
      <dc:date>2012-02-16T07:58:19Z</dc:date>
    </item>
    <item>
      <title>creating mean variable by groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-mean-variable-by-groups/m-p/55315#M15403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; SQL with a GROUP BY that is remerging the statistic with the original query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select group, var1, mean(var1) as var2&lt;/P&gt;&lt;P&gt;from table1&lt;/P&gt;&lt;P&gt;group by group;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 08:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-mean-variable-by-groups/m-p/55315#M15403</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2012-02-16T08:06:14Z</dc:date>
    </item>
  </channel>
</rss>

