<?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: how to calculate average of a subset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350409#M273655</link>
    <description>&lt;P&gt;I think this should give you want you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name $  age;
  cards;
julia       45
julia       54
julia       34
julia       45
jason      23
jason     56
julia       23
jason     11
jason     34
julia       22
alec       31
alex       33
matt       28
jason     29
;
run;

proc sql;
	create table want
	as select
	name,
	age,
	age/mean(age) as score
	from have
	group by name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Apr 2017 00:37:30 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2017-04-17T00:37:30Z</dc:date>
    <item>
      <title>how to calculate average of a subset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350398#M273652</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am pretty new to SAS and I need help in some basic calculations. I want to calculate the average of a subset of numbers in a column and divide every value of that column by the average.&lt;/P&gt;&lt;P&gt;For example, I have a table&amp;nbsp;&lt;/P&gt;&lt;P&gt;name &amp;nbsp;age&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 54&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 34&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;jason &amp;nbsp; &amp;nbsp; &amp;nbsp;23&lt;/P&gt;&lt;P&gt;jason &amp;nbsp; &amp;nbsp; 56&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 23&lt;/P&gt;&lt;P&gt;jason &amp;nbsp; &amp;nbsp; 11&lt;/P&gt;&lt;P&gt;jason &amp;nbsp; &amp;nbsp; 34&lt;/P&gt;&lt;P&gt;julia &amp;nbsp; &amp;nbsp; &amp;nbsp; 22&lt;/P&gt;&lt;P&gt;alec &amp;nbsp; &amp;nbsp; &amp;nbsp; 31&lt;/P&gt;&lt;P&gt;alex &amp;nbsp; &amp;nbsp; &amp;nbsp; 33&lt;/P&gt;&lt;P&gt;matt &amp;nbsp; &amp;nbsp; &amp;nbsp; 28&lt;/P&gt;&lt;P&gt;jason &amp;nbsp; &amp;nbsp; 29&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the average age of Jason and divide every value of age by the average. What is the easiest way to do this and is this something that can be done with proc sql? Thanks in advance for your help!&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 22:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350398#M273652</guid>
      <dc:creator>vseshad</dc:creator>
      <dc:date>2017-04-16T22:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate average of a subset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350401#M273653</link>
      <description>&lt;P&gt;You want to divide everyone's age by Jason's average age?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input name $  age;
  cards;
julia       45
julia       54
julia       34
julia       45
jason      23
jason     56
julia       23
jason     11
jason     34
julia       22
alec       31
alex       33
matt       28
jason     29
;

proc sql noprint;
  select mean(age)
    into :jage
      from have
        where name eq 'jason'
  ;
quit;

data want;
  set have;
  jzcore=age/&amp;amp;jage.;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 23:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350401#M273653</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-16T23:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate average of a subset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350408#M273654</link>
      <description>&lt;P&gt;Your question is ambigous.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you calculating an average per person and dividing each persons value divided by their individual average&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;Are you calculating an average per person and dividing each persons value divided by the total average across all people&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;By Jason's average as indicated?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post sample data and sample output.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 00:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350408#M273654</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-17T00:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate average of a subset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350409#M273655</link>
      <description>&lt;P&gt;I think this should give you want you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name $  age;
  cards;
julia       45
julia       54
julia       34
julia       45
jason      23
jason     56
julia       23
jason     11
jason     34
julia       22
alec       31
alex       33
matt       28
jason     29
;
run;

proc sql;
	create table want
	as select
	name,
	age,
	age/mean(age) as score
	from have
	group by name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Apr 2017 00:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350409#M273655</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-04-17T00:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate average of a subset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350475#M273656</link>
      <description>&lt;P&gt;I apologize if it seems ambiguous. I want to divide each person's value by Jason's average.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 11:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-average-of-a-subset/m-p/350475#M273656</guid>
      <dc:creator>vseshad</dc:creator>
      <dc:date>2017-04-17T11:16:25Z</dc:date>
    </item>
  </channel>
</rss>

