<?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 the mean of all the observations of one variable and add the mean value as a variable on the table for every observation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180543#M302957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input grade;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1.4&lt;/P&gt;&lt;P&gt;3.2&lt;/P&gt;&lt;P&gt;3.4&lt;/P&gt;&lt;P&gt;2.1&lt;/P&gt;&lt;P&gt;4.3&lt;/P&gt;&lt;P&gt;5.4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select grade,avg(grade) as mean from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Jul 2014 20:43:46 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-07-15T20:43:46Z</dc:date>
    <item>
      <title>How to calculate the mean of all the observations of one variable and add the mean value as a variable on the table for every observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180541#M302955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose the 'Grade' variable has 100 observations. I want to calculate the mean of those 100 observations and save the value as one varaible on the table. I know we could easily get the mean through "proc mean", but that will not save the mean value as a new varaible on the same table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2014 20:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180541#M302955</guid>
      <dc:creator>MrBruce</dc:creator>
      <dc:date>2014-07-15T20:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the mean of all the observations of one variable and add the mean value as a variable on the table for every observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180542#M302956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a SQL option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select *, mean(age) as avg_age&lt;/P&gt;&lt;P&gt;from sashelp.class;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2014 20:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180542#M302956</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-15T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the mean of all the observations of one variable and add the mean value as a variable on the table for every observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180543#M302957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input grade;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1.4&lt;/P&gt;&lt;P&gt;3.2&lt;/P&gt;&lt;P&gt;3.4&lt;/P&gt;&lt;P&gt;2.1&lt;/P&gt;&lt;P&gt;4.3&lt;/P&gt;&lt;P&gt;5.4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select grade,avg(grade) as mean from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2014 20:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180543#M302957</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-15T20:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the mean of all the observations of one variable and add the mean value as a variable on the table for every observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180544#M302958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OR, after get mean by proc mean , you can do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc mean noprint;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;output out=mean mean=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; if _n_ eq 1 then set mean;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2014 12:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180544#M302958</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-07-16T12:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the mean of all the observations of one variable and add the mean value as a variable on the table for every observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180545#M302959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an alternative you could loop through your data set yourself and add the mean:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input grade;&lt;BR /&gt;datalines;&lt;BR /&gt;1.4&lt;BR /&gt;3.2&lt;BR /&gt;3.4&lt;BR /&gt;2.1&lt;BR /&gt;4.3&lt;BR /&gt;5.4&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Data Want (Drop=Obs i Total);&lt;BR /&gt;&amp;nbsp; Do Obs=1 By 1 Until (Eof);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Have End=Eof;&lt;BR /&gt; Total=Sum(Total,Grade);&lt;BR /&gt;&amp;nbsp; End;&lt;BR /&gt;&amp;nbsp; Mean=Total/Obs;&lt;BR /&gt;&amp;nbsp; Do i=1 To Obs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Have;&lt;BR /&gt; Output;&lt;BR /&gt;&amp;nbsp; End;&lt;BR /&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 13:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-the-mean-of-all-the-observations-of-one/m-p/180545#M302959</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-12-10T13:55:07Z</dc:date>
    </item>
  </channel>
</rss>

