<?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: Calculate average result excluding current in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301618#M270400</link>
    <description>&lt;P&gt;Thank you so much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;embarrassingly it was the basic logic that was eluding me, I was thinking about how to dynamically exclude one row, it didnt ocur to me to just add everything up then subbract, need to remeber to take a step back sometimes!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2016 19:37:53 GMT</pubDate>
    <dc:creator>itchyeyeballs</dc:creator>
    <dc:date>2016-09-29T19:37:53Z</dc:date>
    <item>
      <title>Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301566#M270394</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do an analysis of student results. For this I'm measuring performance of a student in a particular module vs average performance in all other modules. Can anyone advise how I could go about calculating this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data is very straightforward, 3 columns:&lt;/P&gt;&lt;P&gt;Stud_id&lt;/P&gt;&lt;P&gt;module_id&lt;/P&gt;&lt;P&gt;result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 17:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301566#M270394</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2016-09-29T17:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301573#M270395</link>
      <description>&lt;P&gt;Is each student limited to a single observation per module?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, you might have to provide an example of the results you are looking for (just for one student, but with different numbers of observations per module).&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 17:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301573#M270395</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-29T17:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301596#M270396</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, each student has a single result per module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 18:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301596#M270396</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2016-09-29T18:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301597#M270397</link>
      <description>&lt;P&gt;OK, with one observation per student per module, the programming isn't too difficult:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by stud_id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by stud_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var result;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=summary_stats (keep=n_modules total_result) sum=total_result n=n_modules;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; merge have summary_stats;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by stud_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; other_modules_mean = (total_result - result) / (n_modules - 1);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 18:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301597#M270397</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-29T18:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301605#M270398</link>
      <description>&lt;P&gt;Thank you, very much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I push my luck and ask you to annotate what the code is doing?&amp;nbsp;I'm coming from an MS world so this is very different to me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 18:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301605#M270398</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2016-09-29T18:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301612#M270399</link>
      <description>&lt;P&gt;I can give you the big picture ... but there's no substitute for learning SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS programs, each step runs in order, and independently of the other steps.&amp;nbsp; So PROC SORT completes, then PROC SUMMARY begins.&amp;nbsp; PROC SUMMARY completes, then the DATA step runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SORT puts the observations in order.&amp;nbsp; That is necessary to permit processing BY STUD_ID in later steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SUMMARY creates a summary data set named SUMMARY_STATS.&amp;nbsp; It contains one observation per STUD_ID, with two variables.&amp;nbsp; TOTAL_RESULT is the sum of all the RESULT values for that STUD_ID, and N_MODULES is the number of observations for that STUD_ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step adds those two variables to every original observation, matching by STUD_ID.&amp;nbsp; That match gives you all the information needed for calculations.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 19:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301612#M270399</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-29T19:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average result excluding current</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301618#M270400</link>
      <description>&lt;P&gt;Thank you so much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;embarrassingly it was the basic logic that was eluding me, I was thinking about how to dynamically exclude one row, it didnt ocur to me to just add everything up then subbract, need to remeber to take a step back sometimes!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 19:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-average-result-excluding-current/m-p/301618#M270400</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2016-09-29T19:37:53Z</dc:date>
    </item>
  </channel>
</rss>

