<?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 Selecting MAX VALUE by Visit Number - REVISED in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Selecting-MAX-VALUE-by-Visit-Number-REVISED/m-p/2849#M234</link>
    <description>I have the following data:&lt;BR /&gt;
&lt;BR /&gt;
id score00 score02 score 04&lt;BR /&gt;
1      2           4           1&lt;BR /&gt;
2      4           3           7&lt;BR /&gt;
...and so on.&lt;BR /&gt;
&lt;BR /&gt;
I would like to get the maximum values for each score, going back to all the previous scores. It should look something like this:&lt;BR /&gt;
&lt;BR /&gt;
id score00 score02 score04 maxscore00 maxscore02 maxscore04&lt;BR /&gt;
1     2            4           1              2                4                 4&lt;BR /&gt;
2     4            3           7              4                4                 7&lt;BR /&gt;
...and so on.&lt;BR /&gt;
&lt;BR /&gt;
What is the SAS code I need to get the table above? &lt;BR /&gt;
&lt;BR /&gt;
Thank you very much!</description>
    <pubDate>Wed, 18 Apr 2007 16:00:57 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-04-18T16:00:57Z</dc:date>
    <item>
      <title>Selecting MAX VALUE by Visit Number - REVISED</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Selecting-MAX-VALUE-by-Visit-Number-REVISED/m-p/2849#M234</link>
      <description>I have the following data:&lt;BR /&gt;
&lt;BR /&gt;
id score00 score02 score 04&lt;BR /&gt;
1      2           4           1&lt;BR /&gt;
2      4           3           7&lt;BR /&gt;
...and so on.&lt;BR /&gt;
&lt;BR /&gt;
I would like to get the maximum values for each score, going back to all the previous scores. It should look something like this:&lt;BR /&gt;
&lt;BR /&gt;
id score00 score02 score04 maxscore00 maxscore02 maxscore04&lt;BR /&gt;
1     2            4           1              2                4                 4&lt;BR /&gt;
2     4            3           7              4                4                 7&lt;BR /&gt;
...and so on.&lt;BR /&gt;
&lt;BR /&gt;
What is the SAS code I need to get the table above? &lt;BR /&gt;
&lt;BR /&gt;
Thank you very much!</description>
      <pubDate>Wed, 18 Apr 2007 16:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Selecting-MAX-VALUE-by-Visit-Number-REVISED/m-p/2849#M234</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-04-18T16:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting MAX VALUE by Visit Number - REVISED</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Selecting-MAX-VALUE-by-Visit-Number-REVISED/m-p/2850#M235</link>
      <description>A simple solution might look like this&lt;BR /&gt;
&lt;BR /&gt;
data scores;&lt;BR /&gt;
	set scores;&lt;BR /&gt;
	retain maxscore00 maxscore02 maxscore04;&lt;BR /&gt;
	maxscore00 = max(score00, maxscore00);&lt;BR /&gt;
	maxscore02 = max(score02, maxscore02);&lt;BR /&gt;
	maxscore04 = max(score04, maxscore04);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
But if you have a lot more variables, you might be better off with this version. You would have to expand the retain and array lines with your additional variables, but you wouldn't have to write max functions over and over.&lt;BR /&gt;
&lt;BR /&gt;
data scores;&lt;BR /&gt;
	set scores;&lt;BR /&gt;
	retain maxscore00 maxscore02 maxscore04;&lt;BR /&gt;
	array scorein (3) score00 score02 score04;&lt;BR /&gt;
	array scoremx (3) maxscore00 maxscore02 maxscore04;&lt;BR /&gt;
	do i = 1 to 3;&lt;BR /&gt;
		scoremx&lt;I&gt; = max(scorein&lt;I&gt;, scoremx&lt;I&gt;);&lt;BR /&gt;
	end;&lt;BR /&gt;
	drop i;&lt;BR /&gt;
run;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Thu, 26 Apr 2007 17:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Selecting-MAX-VALUE-by-Visit-Number-REVISED/m-p/2850#M235</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2007-04-26T17:13:49Z</dc:date>
    </item>
  </channel>
</rss>

