<?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: Averaging the values of two variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22399#M4909</link>
    <description>Caitlin,&lt;BR /&gt;
&lt;BR /&gt;
The syntax is correct (except for the missing semi-colon).  The mean function, used in a data step, requires that both the values are present for each observation to get a non-missing result.&lt;BR /&gt;
&lt;BR /&gt;
I wonder if you are really asking a different question, and looking for the mid-range ( &lt;A href="http://en.wikipedia.org/wiki/Midrange" target="_blank"&gt;http://en.wikipedia.org/wiki/Midrange&lt;/A&gt; ) of all observations in a set?&lt;BR /&gt;
&lt;BR /&gt;
If so, you may need to attack it differently:&lt;BR /&gt;
1) PROC MEANS to output the min and max.&lt;BR /&gt;
2) DATA step on the output to get the mid-range.&lt;BR /&gt;
&lt;BR /&gt;
Doc</description>
    <pubDate>Mon, 02 Jun 2008 13:27:47 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2008-06-02T13:27:47Z</dc:date>
    <item>
      <title>Averaging the values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22398#M4908</link>
      <description>We would like to create a new variable that is the average of two variables measuring time. &lt;BR /&gt;
We are trying to find the average of the maximum number of days spent in a program and the minimum number of days. We tried this code: &lt;BR /&gt;
&lt;BR /&gt;
avg=mean(min_days, max_days)&lt;BR /&gt;
&lt;BR /&gt;
But it does not work. Is there a simple formula that sas will understand to create an average like this? &lt;BR /&gt;
&lt;BR /&gt;
Thank you</description>
      <pubDate>Mon, 02 Jun 2008 02:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22398#M4908</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-02T02:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging the values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22399#M4909</link>
      <description>Caitlin,&lt;BR /&gt;
&lt;BR /&gt;
The syntax is correct (except for the missing semi-colon).  The mean function, used in a data step, requires that both the values are present for each observation to get a non-missing result.&lt;BR /&gt;
&lt;BR /&gt;
I wonder if you are really asking a different question, and looking for the mid-range ( &lt;A href="http://en.wikipedia.org/wiki/Midrange" target="_blank"&gt;http://en.wikipedia.org/wiki/Midrange&lt;/A&gt; ) of all observations in a set?&lt;BR /&gt;
&lt;BR /&gt;
If so, you may need to attack it differently:&lt;BR /&gt;
1) PROC MEANS to output the min and max.&lt;BR /&gt;
2) DATA step on the output to get the mid-range.&lt;BR /&gt;
&lt;BR /&gt;
Doc</description>
      <pubDate>Mon, 02 Jun 2008 13:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22399#M4909</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2008-06-02T13:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging the values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22400#M4910</link>
      <description>Based on your code, you want something that looks like this.&lt;BR /&gt;
&lt;BR /&gt;
Name      min_days    max_days    avg&lt;BR /&gt;
John           5                10             7.5&lt;BR /&gt;
Joan           1                14             7.5 &lt;BR /&gt;
Pat             5                16            10.5&lt;BR /&gt;
&lt;BR /&gt;
What is happening when you run your code because that code looks correct?&lt;BR /&gt;
&lt;BR /&gt;
If the midrange across all data is what you want, try this:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select mean(min(min_days),Max(max_days)) from work.data;&lt;BR /&gt;
&lt;BR /&gt;
It will give you the single mean of 8.5 between just 1 and 16.</description>
      <pubDate>Thu, 05 Jun 2008 04:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Averaging-the-values-of-two-variables/m-p/22400#M4910</guid>
      <dc:creator>rab24</dc:creator>
      <dc:date>2008-06-05T04:56:40Z</dc:date>
    </item>
  </channel>
</rss>

