<?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 with proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307826#M65989</link>
    <description>Dear RW9;&lt;BR /&gt;Thanks for your comment, I used your guideline for some other purpose, was really useful.</description>
    <pubDate>Fri, 28 Oct 2016 03:28:51 GMT</pubDate>
    <dc:creator>Marzi</dc:creator>
    <dc:date>2016-10-28T03:28:51Z</dc:date>
    <item>
      <title>mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307667#M65926</link>
      <description>&lt;P&gt;I'm wondering why when I add any of the&amp;nbsp;second means, the result is zero?!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data error;
input actual predicted;
datalines;
4   5 
6   6
9   8
10  10
4   4
6   8
4   4
7   9
8   8
7   5
;
run;
proc sql;
    select mean((mean(actual) - actual)**2) format 20.3 into :adjrsq from error;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;sorry if my question is very simple to solve, I'm very beginner&amp;nbsp;in SAS!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 15:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307667#M65926</guid>
      <dc:creator>Marzi</dc:creator>
      <dc:date>2016-10-27T15:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307677#M65929</link>
      <description>&lt;P&gt;What is it your trying to do? &amp;nbsp;The mean function will return one record, which is the mean, and that row will also contain the value which is the same. &amp;nbsp;So say 4 is the mean value of all that data, then the line your working on looks like this:&lt;/P&gt;
&lt;P&gt;mean=4, actual=4&lt;/P&gt;
&lt;P&gt;so:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;mean&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;4&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; 4&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;**&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will always return 0, as 4-4 is 0.&lt;/P&gt;
&lt;P&gt;Maybe you want to merge mean onto the data so that you have all the data and mean:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table INTER as 
  select A.*,
           B.MEAN
  from   ERROR A
  left join (select mean(ACTUAL) as MEAN from ERROR) B
  on      1=1;
  create table WANT as
  select  mean((MEAN - ACTUAL)**2) 
  into :ADJRSQ 
  from INTER;
quit;
&lt;/PRE&gt;
&lt;P&gt;You could shrink the code above, but I am showing the interveening step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 15:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307677#M65929</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-27T15:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307710#M65936</link>
      <description>Just want to add that mean() with one argument will be executed as the SQL aggregate function (for all records, or per GROUP BY if specified). &lt;BR /&gt;With multiple arguments it's the SAS Language function that gets executed and will return the mean of the listed arguments (for each record).</description>
      <pubDate>Thu, 27 Oct 2016 17:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307710#M65936</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-27T17:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307727#M65943</link>
      <description>&lt;P&gt;I think what you want is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    select mean(
        ((select mean(actual) from error) - actual)**2) format 20.3 
    into :adjrsq 
from error;
quit;

%put &amp;amp;adjrsq;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Oct 2016 18:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307727#M65943</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-27T18:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307826#M65989</link>
      <description>Dear RW9;&lt;BR /&gt;Thanks for your comment, I used your guideline for some other purpose, was really useful.</description>
      <pubDate>Fri, 28 Oct 2016 03:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307826#M65989</guid>
      <dc:creator>Marzi</dc:creator>
      <dc:date>2016-10-28T03:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: mean with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307827#M65990</link>
      <description>Thanks PG Stats</description>
      <pubDate>Fri, 28 Oct 2016 03:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mean-with-proc-sql/m-p/307827#M65990</guid>
      <dc:creator>Marzi</dc:creator>
      <dc:date>2016-10-28T03:29:29Z</dc:date>
    </item>
  </channel>
</rss>

