<?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: a mixture of many ways to calculating in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367465#M87478</link>
    <description>&lt;P&gt;It takes a little work, but you can get the values in this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set old;&lt;/P&gt;
&lt;P&gt;retain score1 score2;&lt;/P&gt;
&lt;P&gt;****************** more statements to calculate SCORE&lt;/P&gt;
&lt;P&gt;if rownum=1 then score1 = score;&lt;/P&gt;
&lt;P&gt;else if rownum=2 then score2 = score;&lt;/P&gt;
&lt;P&gt;drop score1 score2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now SCORE1 is the calculated SCORE value for ROWNUM=1, and presumably gets calculated before it is needed to generate SCORE values for later values of ROWNUM.&amp;nbsp; Just use SCORE1 and SCORE2 as part of&amp;nbsp; your SCORE calculations.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 17:56:41 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-15T17:56:41Z</dc:date>
    <item>
      <title>a mixture of many ways to calculating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367458#M87474</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I need to modify a program; originally, it is a very simple data step.

Data want;
Set old;
Where rownum=3;
Run;

Now I need to add some new rules because of different ways of calculating the score, instead of just pick up the score on the third row before. I cannot pick the third row (one size does not fit all!).
The rules are listed as follows

1.	If id in (‘4’,’5’,’110’,’119,’1000’) then score=sum1/sum2;
2.	If id in (‘34’,’12’,’245’,’beaa’,’geee2’) then score= sum(aver)/sumrownum:
3.	If id in (‘rt’, ‘t32’,’g45’,’2’,’578’) then score = score where appears on the first row, that is rownum=1
4.	If id in (‘a2’,’c34’) then score=score where appears on the second row, that is rownum=2;
….
So I am thinking of doing this in a datastep, it would be easy for the first two steps, but for the last two, it seems that I need use “where…” and I do not know how to do. Or do I have to set up a subdataset? That will be time consuming

Can anybody show me how to do? Thanks.


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367458#M87474</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2017-06-15T17:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: a mixture of many ways to calculating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367461#M87477</link>
      <description>&lt;P&gt;1. Post sample data&lt;/P&gt;
&lt;P&gt;2. Post sample expected output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367461#M87477</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T17:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: a mixture of many ways to calculating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367465#M87478</link>
      <description>&lt;P&gt;It takes a little work, but you can get the values in this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set old;&lt;/P&gt;
&lt;P&gt;retain score1 score2;&lt;/P&gt;
&lt;P&gt;****************** more statements to calculate SCORE&lt;/P&gt;
&lt;P&gt;if rownum=1 then score1 = score;&lt;/P&gt;
&lt;P&gt;else if rownum=2 then score2 = score;&lt;/P&gt;
&lt;P&gt;drop score1 score2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now SCORE1 is the calculated SCORE value for ROWNUM=1, and presumably gets calculated before it is needed to generate SCORE values for later values of ROWNUM.&amp;nbsp; Just use SCORE1 and SCORE2 as part of&amp;nbsp; your SCORE calculations.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-mixture-of-many-ways-to-calculating/m-p/367465#M87478</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-15T17:56:41Z</dc:date>
    </item>
  </channel>
</rss>

