<?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: Combine the results of proc means in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335133#M62927</link>
    <description>&lt;P&gt;Forget the procedure. Explain what you want in plain english, because I don't understand as is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have multiple data sets you're working with, or multiple variables within a data set, or multiple groups within a dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe provide a small sample of fictional data that illustrates your issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I assume you have three different variables and you want the average of averages then this would work - make sure that you account for the different number of observations especially if you have missing values anywhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data class;
  set sashelp.class;

  weight2=weight+5;
  weight3 =weight+3;
  run;

  proc means data=class stackods mean;
  var weight weight2 weight3;
  ods output summary=mean_weight;
  run;

  proc means data=mean_weight;
  var mean;
  output out=want_p_means mean(mean)=average;
  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Feb 2017 22:02:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-02-22T22:02:10Z</dc:date>
    <item>
      <title>Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335124#M62924</link>
      <description>&lt;P&gt;I am trying to combine 3 results into 1, renaming it and getting the mean of those 3 results. &amp;nbsp;I have searched and searched but can't find any info on this, except for using a by or class statement, which is not what I am looking for, so far I only have this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc mean data=pat_info;&lt;BR /&gt;var result1 result2 result3;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 21:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335124#M62924</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2017-02-22T21:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335126#M62925</link>
      <description>&lt;P&gt;Your question is ambiguous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to take the average of 3 values that are already averages?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or combining 3 datasets to get one average?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 21:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335126#M62925</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-22T21:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335130#M62926</link>
      <description>&lt;P&gt;Sorry. never done this procedure before. &amp;nbsp;I am trying to create a variable, for example mean_result,&amp;nbsp;using 3 different variable averages with 15 observations. &amp;nbsp;I need to combine the 3 result averages to get the mean for all 3 results, for all 15 obsv.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 21:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335130#M62926</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2017-02-22T21:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335133#M62927</link>
      <description>&lt;P&gt;Forget the procedure. Explain what you want in plain english, because I don't understand as is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have multiple data sets you're working with, or multiple variables within a data set, or multiple groups within a dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe provide a small sample of fictional data that illustrates your issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I assume you have three different variables and you want the average of averages then this would work - make sure that you account for the different number of observations especially if you have missing values anywhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data class;
  set sashelp.class;

  weight2=weight+5;
  weight3 =weight+3;
  run;

  proc means data=class stackods mean;
  var weight weight2 weight3;
  ods output summary=mean_weight;
  run;

  proc means data=mean_weight;
  var mean;
  output out=want_p_means mean(mean)=average;
  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 22:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335133#M62927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-22T22:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335135#M62928</link>
      <description>&lt;P&gt;Result1 Result2 Result3&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.4&lt;BR /&gt;2.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5&lt;BR /&gt;1.9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;BR /&gt;1.4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.4&lt;BR /&gt;10.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.2&lt;BR /&gt;3.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.2&lt;BR /&gt;3.9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.6&lt;BR /&gt;4.7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;7.8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.6&lt;BR /&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;4.4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;6.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;1.6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;BR /&gt;1.8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above is the 3 variables I have. I am trying to create a variable mean_result, which is the mean of the above 3 variables.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 22:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335135#M62928</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2017-02-22T22:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the results of proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335146#M62929</link>
      <description>&lt;P&gt;A very long work through but several solutions are here, 3, 2 work and 1 isn't correct but is done to illustrate the issue with that method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Result1 Result2 Result3;
cards;
4              4.2          4.4
2.3           3.4          4.5
1.9           4.3             6
1.4           1.4          1.4
10.3            9          5.2
3.5           3.3          5.2
3.9              5          7.6
4.7           7.3             1
7.8           1.3         5.6
4               5.1            .
4.4            1.5           2
6                   .            .
6.3                .            .
1.6            1.6             .
1.8            2.3         2.3
;
run;

*WRONG WAY to do this;
  proc means data=have  noprint;
  var Result: ;
  output out=summary_mean mean(result1)=result1 mean(result2)=result2 mean(result3)=result3;
  run;

data wrong_answer;
set summary_mean;
solution = mean(result1, result2, result3);
run;

*One step data step solution;
  data data_step_solution;
  set have end=eof;
  retain running_total running_count;
  Running_total = sum(running_total, result1, result2, result3);
  Running_count = sum(running_count, n(result1, result2, result3));

  if eof then do;
     mean = running_total/running_count;
     output;
  end;

  keep mean;
  run;

  *Combine via a view and then proc means;
  data combined /view=combined;
  set have(rename=result1=result )
  have(rename=result2=result)
  have(rename=result3=result);
  keep result;
  run;

 
  proc means data=combined noprint;
  var result;
  output out=mean_result mean(result)=mean_result;
  run;

  title "Wrong answer - doesn't account for missing";
  proc print data=wrong_answer;
  run;
  title "Answer from data step";
    proc print data=data_step_solution;
  run;
  title "Answer from proc means with view";
    proc print data=mean_result;
  run;




 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 23:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-the-results-of-proc-means/m-p/335146#M62929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-22T23:12:08Z</dc:date>
    </item>
  </channel>
</rss>

