<?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: Harmonic Mean in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10279#M951</link>
    <description>For Harmonic anyways why not:&lt;BR /&gt;
&lt;BR /&gt;
Just augment your table with reciprocals then take the reciprocal of the reported mean from PROC MEANS?&lt;BR /&gt;
&lt;BR /&gt;
Ike Eisenhauer</description>
    <pubDate>Wed, 09 Apr 2008 20:00:36 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-09T20:00:36Z</dc:date>
    <item>
      <title>Harmonic Mean</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10278#M950</link>
      <description>For the first time in my career, I have a need to calculate a harmonic mean across a large number of observations (harmean function is out and impractical).&lt;BR /&gt;
&lt;BR /&gt;
I was completely surprised that proc means does not provide an option for harmonic and geometric means.&lt;BR /&gt;
&lt;BR /&gt;
Is there a proc that has these alternate means available?</description>
      <pubDate>Wed, 09 Apr 2008 18:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10278#M950</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-09T18:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Harmonic Mean</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10279#M951</link>
      <description>For Harmonic anyways why not:&lt;BR /&gt;
&lt;BR /&gt;
Just augment your table with reciprocals then take the reciprocal of the reported mean from PROC MEANS?&lt;BR /&gt;
&lt;BR /&gt;
Ike Eisenhauer</description>
      <pubDate>Wed, 09 Apr 2008 20:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10279#M951</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-09T20:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Harmonic Mean</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10280#M952</link>
      <description>Chuck&lt;BR /&gt;
&lt;BR /&gt;
I assume you have many variables and many observations to process. So transposing the data and using the SAS function HARMEAN would be impractical.  Imagine transposing a data set with millions of rows!.&lt;BR /&gt;
&lt;BR /&gt;
This isn't the most elegant solution but it gets the job done.   With a little work I am confident that you can come up with an elegant solution for you specific problem.&lt;BR /&gt;
&lt;BR /&gt;
I tried to mimic the harmean function in SAS.  In the SAS documentation if any value is negative then the result is missing. And missing values need to be ignored.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
input x;&lt;BR /&gt;
datalines;&lt;BR /&gt;
. &lt;BR /&gt;
4&lt;BR /&gt;
12&lt;BR /&gt;
24&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data two;&lt;BR /&gt;
  set one end=eof;&lt;BR /&gt;
&lt;BR /&gt;
  if x &amp;lt;0 and not missing(X) then negative_flag+1;&lt;BR /&gt;
  x1=1/x;&lt;BR /&gt;
  cum_x+x1;&lt;BR /&gt;
  n+1;&lt;BR /&gt;
  if missing(x) then n=n-1;&lt;BR /&gt;
&lt;BR /&gt;
  if eof and not negative_flag then do;&lt;BR /&gt;
    x_harmonic_mean=1/(cum_x/n);&lt;BR /&gt;
    put x_harmonic_mean;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  x2=harmean(.,4,12,24);&lt;BR /&gt;
  put x2=;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-Darryl</description>
      <pubDate>Thu, 10 Apr 2008 13:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Harmonic-Mean/m-p/10280#M952</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2008-04-10T13:32:28Z</dc:date>
    </item>
  </channel>
</rss>

