<?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: excludes the lowest value when calculating mean in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/588317#M168118</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for small size data arrays sounds reasonable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fullstimer;
data have;                                                                                                               
do nums=1 to 5555555;                                                                                                       
  num=int(10*uniform(1234))+2; 
    if mod(nums,17) = 0 then num =.; 
  output;                                                                                                             
end;                                                                                                                   
run;     

data _null_;
  if 0 then set have nobs=NOBS;
       call symputX('NOBS', NOBS,'G');
  stop;
run;


data want;
  array _temp_[&amp;amp;nobs.] _temporary_;

  x = .;
  do until (EOF);
    set have end=EOF curobs=curobs;
    _temp_[curobs] = num;
    x = x&amp;lt;&amp;gt;(-num);
  end;
  
  x = -x;

  if x = . 
  then avg = .;
  else do curobs = lbound(_temp_) to hbound(_temp_);
    if _temp_[curobs] &amp;gt; x then 
      do;
        s + _temp_[curobs];
        c + 1;
      end;
  end;

  avg = divide(s,c);
  output;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2019 17:21:09 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2019-09-12T17:21:09Z</dc:date>
    <item>
      <title>excludes the lowest value when calculating mean in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586609#M167467</link>
      <description>&lt;P&gt;So, My professor asked me to create a&amp;nbsp; SAS program to excludes the lowest midterm grades when computing the prefinal grades(mean of exams), I google it, and it's have nothing help there,&amp;nbsp; I can't find appropriate code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for help&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 03:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586609#M167467</guid>
      <dc:creator>Uzeus7869</dc:creator>
      <dc:date>2019-09-06T03:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: excludes the lowest value when calculating mean in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586613#M167470</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So, My professor asked me to create a&amp;nbsp; SAS program to excludes the lowest midterm grades when computing the prefinal grades(mean of exams), I google it, and it's have nothing help there,&amp;nbsp; I can't find appropriate code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Surely your professor also gave you hints as to how to do this.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 03:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586613#M167470</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-06T03:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: excludes the lowest value when calculating mean in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586614#M167471</link>
      <description>&lt;P&gt;How would you calculate the mean without excluding the lowest values?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 03:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/586614#M167471</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-06T03:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: excludes the lowest value when calculating mean in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/588317#M168118</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for small size data arrays sounds reasonable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fullstimer;
data have;                                                                                                               
do nums=1 to 5555555;                                                                                                       
  num=int(10*uniform(1234))+2; 
    if mod(nums,17) = 0 then num =.; 
  output;                                                                                                             
end;                                                                                                                   
run;     

data _null_;
  if 0 then set have nobs=NOBS;
       call symputX('NOBS', NOBS,'G');
  stop;
run;


data want;
  array _temp_[&amp;amp;nobs.] _temporary_;

  x = .;
  do until (EOF);
    set have end=EOF curobs=curobs;
    _temp_[curobs] = num;
    x = x&amp;lt;&amp;gt;(-num);
  end;
  
  x = -x;

  if x = . 
  then avg = .;
  else do curobs = lbound(_temp_) to hbound(_temp_);
    if _temp_[curobs] &amp;gt; x then 
      do;
        s + _temp_[curobs];
        c + 1;
      end;
  end;

  avg = divide(s,c);
  output;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 17:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excludes-the-lowest-value-when-calculating-mean-in-SAS/m-p/588317#M168118</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-09-12T17:21:09Z</dc:date>
    </item>
  </channel>
</rss>

