<?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: How to exclude the lowest numbers when finding mean in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892473#M352473</link>
    <description>&lt;P&gt;Please do always (as in&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt;) post example data as text, preferably as DATA step code with DATALINES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transpose your dataset to a long layout (there should be some kind of student id to use in the BY).&lt;/P&gt;
&lt;P&gt;Sort by value, and DELETE the observations where the name contains exam and FIRST.(id) is true. Then use PROC SUMMARY to get the mean.&lt;/P&gt;</description>
    <pubDate>Sun, 03 Sep 2023 08:02:36 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-09-03T08:02:36Z</dc:date>
    <item>
      <title>How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892471#M352472</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;SPAN&gt;Hello.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have exam scores and I need to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;write a SAS program in which the DATA step reads &lt;/SPAN&gt;&lt;SPAN&gt;all &lt;/SPAN&gt;&lt;FONT face="inherit"&gt;the scores using INFILE and then excludes the lowest midterm score when calculating the mean. I need help &lt;/FONT&gt;with&lt;FONT face="inherit"&gt;&amp;nbsp;how to exclude the lowest &lt;/FONT&gt;midterm&lt;FONT face="inherit"&gt;&amp;nbsp;scores when &lt;/FONT&gt;calculating&lt;FONT face="inherit"&gt;&amp;nbsp;mean? Data is attached. Thanks&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 03 Sep 2023 06:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892471#M352472</guid>
      <dc:creator>Dna53582</dc:creator>
      <dc:date>2023-09-03T06:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892473#M352473</link>
      <description>&lt;P&gt;Please do always (as in&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt;) post example data as text, preferably as DATA step code with DATALINES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transpose your dataset to a long layout (there should be some kind of student id to use in the BY).&lt;/P&gt;
&lt;P&gt;Sort by value, and DELETE the observations where the name contains exam and FIRST.(id) is true. Then use PROC SUMMARY to get the mean.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 08:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892473#M352473</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-03T08:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892478#M352476</link>
      <description>&lt;P&gt;Some of us refuse to download attachments, and so we request (a portion of) the data be provided as text, and as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please show us&amp;nbsp; the SAS code you have tried so far.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 10:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892478#M352476</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-03T10:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892482#M352480</link>
      <description>&lt;P&gt;Take a moment to read about various &lt;A href="https://blogs.sas.com/content/iml/2022/01/26/k-smallest-largest-data.html" target="_self"&gt;ways to find the smallest value in SAS.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you want to exclude the lowest score from Exam1-Exam5, but not the Final?&lt;/P&gt;
&lt;P&gt;You can do this computation by using the SMALLEST function to find the smallest value in the array. Subtract that value from the full sum of the array.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Want;
set Have;
array Exam[5] Exam1-Exam5;
/* sum of all scores, drop lowest Exam but keep Final */
Sum = sum(of Exam[*]) - smallest(1, of Exam[*]) + Final;
Average = Sum / 5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The advantage of this method is that there is no need to transpose or sort.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 11:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892482#M352480</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-09-03T11:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892484#M352482</link>
      <description>&lt;P&gt;Shouldn't we divide by 4, after removing one element?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 12:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892484#M352482</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-03T12:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892488#M352485</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Shouldn't we divide by 4, after removing one element?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think so, since the FINAL was added to the numerator, summing the 4 highest from (EXAM1 .. EXAM5) and the final.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 14:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892488#M352485</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-09-03T14:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892489#M352486</link>
      <description>&lt;P&gt;That works as long as skipped exams are recorded as zero instead of missing.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 15:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892489#M352486</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-03T15:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude the lowest numbers when finding mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892490#M352487</link>
      <description>&lt;P&gt;Most grading rubrics assign different weights to the midterm and final scores.&amp;nbsp; Some might give the final extra weight. Others give the final equal or smaller weight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a formula based solution where you can adjust the weighting when generating the overall grade.&lt;/P&gt;
&lt;P&gt;For example we could make the final count for 60% of the overall grade.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  excluded=-min(of exam1-exam5);
  if n(of exam1-exam5) &amp;lt; 5 then excluded=0;
  exams = sum(of exam1-exam5 excluded)/4; 
  final_wt=0.6;
  exam_wt=0.4;
  grade = exam_wt*exams + final_wt*final;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So&amp;nbsp; with that weighting the study with the higher final score gets a better overall grade.&lt;/P&gt;
&lt;PRE&gt;Obs id exam1 exam2 exam3 exam4 exam5 final excluded exams final_wt exam_wt grade

 1  1   100   100   100   100     0    90       0    100     0.6     0.4     94
 2  2    90    90    90    90    85   100     -85     90     0.6     0.4     96
&lt;/PRE&gt;
&lt;P&gt;If you want each of the included exams and the final to have equal weight then use FINAL_WT=.2 and EXAM_WT=.8.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the student with the higher mid term scores does better than the student with the higher final score.&lt;/P&gt;
&lt;PRE&gt;Obs id exam1 exam2 exam3 exam4 exam5 final excluded exams final_wt exam_wt grade

 1  1   100   100   100   100     0    90       0    100     0.2     0.8     98
 2  2    90    90    90    90    85   100     -85     90     0.2     0.8     92

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 15:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exclude-the-lowest-numbers-when-finding-mean/m-p/892490#M352487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-03T15:30:12Z</dc:date>
    </item>
  </channel>
</rss>

