<?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: Mean of Subgroup in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758524#M239507</link>
    <description>&lt;P&gt;You can use PROC SUMMARY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
class race sex;
var cholesterol;
output
  out=want
  avg()=
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Jul 2021 20:49:52 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-07-30T20:49:52Z</dc:date>
    <item>
      <title>Mean of Subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758518#M239504</link>
      <description>&lt;P&gt;If I want to calculate the mean of a subgroup (for example I want to calculate the mean cholesterol of White men and White women) and I have variables for cholesterol, race, and sex, how would I combine the variables I need in order to get the averages I am looking for?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758518#M239504</guid>
      <dc:creator>sassypixie</dc:creator>
      <dc:date>2021-07-30T20:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Mean of Subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758524#M239507</link>
      <description>&lt;P&gt;You can use PROC SUMMARY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
class race sex;
var cholesterol;
output
  out=want
  avg()=
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758524#M239507</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-30T20:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Mean of Subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758525#M239508</link>
      <description>&lt;P&gt;I actually tried a different way although I am not 100% sure if it's correct&lt;/P&gt;&lt;PRE&gt;Proc means data=data;&lt;BR /&gt;var cholesterol;&lt;BR /&gt;class sex;&lt;BR /&gt;where race= 2;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;Would this way be still sufficient?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758525#M239508</guid>
      <dc:creator>sassypixie</dc:creator>
      <dc:date>2021-07-30T20:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Mean of Subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758526#M239509</link>
      <description>&lt;P&gt;Typically I would use Proc Summary to create a data set if that is the need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=have;
   class sex race;
   var cholesterol;
   output out=work.summary mean=;
run;&lt;/PRE&gt;
&lt;P&gt;The resulting data will have summary of 1) overall 2)each level of sex, 3)each level of race and 4) each combination of sex and race that appears in the data with the mean for each group. There is a variable _type_ that can be used to select which "group" you want for other processing. If you had other variables that you want to summarize, such as weight, blood pressure or what have you, add those variables to the VAR statement. If you want more statistics then add them such as min= max= std= /autoname. The Autoname option appends the statistics abbreviation to the variable name so you can tell the values apart. If only one statistic is used then the above syntax uses the existing name and it is up to you to know that it is a mean value.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758526#M239509</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-30T20:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Mean of Subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758539#M239517</link>
      <description>&lt;P&gt;You can apply a WHERE to race instead of having it in the CLASS, but the rest of the code should be same.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 21:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-of-Subgroup/m-p/758539#M239517</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-30T21:16:29Z</dc:date>
    </item>
  </channel>
</rss>

