<?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: Calculating the mean of three variables with condition in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-the-mean-of-three-variables-with-condition/m-p/286592#M59508</link>
    <description>&lt;P&gt;Code is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(SBP3) 
	then SBP = mean(SBP1, SBP2);
else 
	if abs(SBP3-SBP1) &amp;lt; abs(SBP3-SBP2) 
		then SBP = mean(SBP1, SBP3);
	else SBP = mean(SBP2, SBP3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(not tested)&lt;/P&gt;</description>
    <pubDate>Sat, 23 Jul 2016 17:43:14 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-07-23T17:43:14Z</dc:date>
    <item>
      <title>Calculating the mean of three variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-the-mean-of-three-variables-with-condition/m-p/286583#M59507</link>
      <description>&lt;P&gt;I'm working with BP data - where in they have measured SBP and DBP.&lt;/P&gt;
&lt;P&gt;1. I have SBP and DBP measured twice as - SBP1 and SBP2&lt;/P&gt;
&lt;P&gt;2. I have the data for SBP3 if - the difference between SBP1 and SBP2 is more than 10&lt;/P&gt;
&lt;DIV class="text_exposed_show"&gt;
&lt;P&gt;3. I would like to calculate mean SBP using SBP1 and SBP2 if there is no data for SBP3&lt;/P&gt;
&lt;P&gt;4. I would like to calculate mean SBP using SBP3 along with SBP2 or SBP1 - based which values (SBP1 or SBP2) are nearest to SBP3.&lt;/P&gt;
&lt;P&gt;Can someone suggest me a code for this?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if SBP3 is missing then SBP = mean (SBP1, SBP2); else if the diff of SBP1 and SBP2 &amp;gt; 10 then use SBP3; SBP = Mean (SBP1 and SBP3) if abs(SBP3-SBP1) &amp;lt; (SBP2 and SBP3); SBP = Mean (SBP2 and SBP3) if abs(SBP2-SBP3) &amp;lt; (SBP1 and SBP3); run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 23 Jul 2016 16:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-the-mean-of-three-variables-with-condition/m-p/286583#M59507</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2016-07-23T16:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the mean of three variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-the-mean-of-three-variables-with-condition/m-p/286592#M59508</link>
      <description>&lt;P&gt;Code is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(SBP3) 
	then SBP = mean(SBP1, SBP2);
else 
	if abs(SBP3-SBP1) &amp;lt; abs(SBP3-SBP2) 
		then SBP = mean(SBP1, SBP3);
	else SBP = mean(SBP2, SBP3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(not tested)&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jul 2016 17:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-the-mean-of-three-variables-with-condition/m-p/286592#M59508</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-23T17:43:14Z</dc:date>
    </item>
  </channel>
</rss>

