<?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 How to select the max value from a range of measurements over time in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326895#M9521</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I have a dataset where four scores were measured over time (R_score, M_score, S_score, and P_score). I have successfully matched these measurements to the time periods during which the subjects (e.g. STUDYID 0001 and 0002) were in a particular environment (SCHOOL vs. HOME). When I say "time period",&lt;/SPAN&gt;&amp;nbsp;this refers to a period of time marked by the same dates and environment. In this case, the first subject 0001 has multiple (14) observations/measurements taken in the SCHOOL environment during the time period&amp;nbsp;&lt;SPAN&gt;02/06/2008-03/12/2010&lt;/SPAN&gt;, followed by a period of time (&lt;SPAN&gt;03/13/2010-01/01/2015)&amp;nbsp;&lt;/SPAN&gt;in the HOME environment&amp;nbsp;during which no measurements were taken and thus the R_score, M_score, S_score, and P_score variables are all missing (which is still useful data to retain for my purposes).&amp;nbsp;&lt;SPAN class="s1"&gt;Sample data is below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; tempfile;&lt;/P&gt;&lt;P class="p2"&gt;infile&lt;SPAN class="s2"&gt; datalines &lt;/SPAN&gt;truncover&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;INPUT&lt;/P&gt;&lt;P class="p1"&gt;environment$ studyID&lt;SPAN class="s3"&gt;$4.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; StartDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; EndDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;daysbwn Movementcode Movecode short_inc count&lt;/P&gt;&lt;P class="p1"&gt;ScoreDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; R_Score M_Score S_Score P_Score;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s4"&gt;format&lt;/SPAN&gt; Startdate EndDate ScoreDate &lt;SPAN class="s3"&gt;yymmdd10.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;datalines&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/06/2008 1 3 3 1&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/08/2008 1 3 3 1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/12/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 03/17/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 05/21/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/06/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/26/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/29/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/27/2009 1 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/28/2009 1 4 4 3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/26/2009 1 5 4 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 09/16/2009 1 4 5 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 12/14/2009 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/27/2010 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;HOME&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 08/01/2007 2 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 02/21/2008 2 2 2 1&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;;&lt;/P&gt;&lt;P class="p3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s4"&gt;data&lt;/SPAN&gt;=tempfile; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;Now I would like to select out the highest value seen for each of the four different score variables during each time period. For example (using red text to indicate the measurements of interest):&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/06/2008 1 3 3 1&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/08/2008 1 3 3 1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/12/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 03/17/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 05/21/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/06/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/26/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/29/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/27/2009 1&lt;/FONT&gt; 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/28/2009&lt;/FONT&gt; 1 4 4 &lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/26/2009 &lt;FONT color="#000000"&gt;1&lt;/FONT&gt; 5 &lt;FONT color="#000000"&gt;4 2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 09/16/2009&lt;/FONT&gt; 1 4 &lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt; 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 12/14/2009 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/27/2010 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 08/01/2007 2 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 02/21/2008 2 2 2 1&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;If only a single row of measurements or only missing values are available, they should be the values chosen and kept in the dataset. If multiple rows of data are available, then the highest value available for each of the score variables should be chosen to produce something that looks like this (the ScoreDate can be dropped):&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;environment$ studyID&lt;SPAN class="s3"&gt;$4.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; StartDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; EndDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;daysbwn Movementcode Movecode short_inc count R_Score M_Score S_Score P_Score&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2&lt;/FONT&gt; 1 &lt;SPAN&gt;5 5&lt;/SPAN&gt;&amp;nbsp;3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN&gt;HOME&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 &lt;FONT color="#FF0000"&gt;. . . .&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1&lt;/FONT&gt;&amp;nbsp;. . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2&lt;/FONT&gt; 2 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3&lt;/FONT&gt; . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4&lt;/FONT&gt; 2 2 2 1&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5&lt;/FONT&gt; . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;Any help to do this properly would be very much appreciated! Thank you in advance.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jan 2017 21:08:18 GMT</pubDate>
    <dc:creator>Kels123</dc:creator>
    <dc:date>2017-01-24T21:08:18Z</dc:date>
    <item>
      <title>How to select the max value from a range of measurements over time</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326895#M9521</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I have a dataset where four scores were measured over time (R_score, M_score, S_score, and P_score). I have successfully matched these measurements to the time periods during which the subjects (e.g. STUDYID 0001 and 0002) were in a particular environment (SCHOOL vs. HOME). When I say "time period",&lt;/SPAN&gt;&amp;nbsp;this refers to a period of time marked by the same dates and environment. In this case, the first subject 0001 has multiple (14) observations/measurements taken in the SCHOOL environment during the time period&amp;nbsp;&lt;SPAN&gt;02/06/2008-03/12/2010&lt;/SPAN&gt;, followed by a period of time (&lt;SPAN&gt;03/13/2010-01/01/2015)&amp;nbsp;&lt;/SPAN&gt;in the HOME environment&amp;nbsp;during which no measurements were taken and thus the R_score, M_score, S_score, and P_score variables are all missing (which is still useful data to retain for my purposes).&amp;nbsp;&lt;SPAN class="s1"&gt;Sample data is below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; tempfile;&lt;/P&gt;&lt;P class="p2"&gt;infile&lt;SPAN class="s2"&gt; datalines &lt;/SPAN&gt;truncover&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;INPUT&lt;/P&gt;&lt;P class="p1"&gt;environment$ studyID&lt;SPAN class="s3"&gt;$4.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; StartDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; EndDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;daysbwn Movementcode Movecode short_inc count&lt;/P&gt;&lt;P class="p1"&gt;ScoreDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; R_Score M_Score S_Score P_Score;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s4"&gt;format&lt;/SPAN&gt; Startdate EndDate ScoreDate &lt;SPAN class="s3"&gt;yymmdd10.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;datalines&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/06/2008 1 3 3 1&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/08/2008 1 3 3 1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/12/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 03/17/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 05/21/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/06/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/26/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/29/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/27/2009 1 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/28/2009 1 4 4 3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/26/2009 1 5 4 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 09/16/2009 1 4 5 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 12/14/2009 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/27/2010 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;HOME&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 08/01/2007 2 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 02/21/2008 2 2 2 1&lt;/P&gt;&lt;P class="p1"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;;&lt;/P&gt;&lt;P class="p3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s2"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s4"&gt;data&lt;/SPAN&gt;=tempfile; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;Now I would like to select out the highest value seen for each of the four different score variables during each time period. For example (using red text to indicate the measurements of interest):&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/06/2008 1 3 3 1&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/08/2008 1 3 3 1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 02/12/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 03/17/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 05/21/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/06/2008 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/26/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/29/2009 1 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/27/2009 1&lt;/FONT&gt; 3 3 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 07/28/2009&lt;/FONT&gt; 1 4 4 &lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 08/26/2009 &lt;FONT color="#000000"&gt;1&lt;/FONT&gt; 5 &lt;FONT color="#000000"&gt;4 2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 09/16/2009&lt;/FONT&gt; 1 4 &lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt; 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 12/14/2009 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2 01/27/2010 1 4 4 2&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2 08/01/2007 2 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 . . . . .&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4 02/21/2008 2 2 2 1&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5 . . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;If only a single row of measurements or only missing values are available, they should be the values chosen and kept in the dataset. If multiple rows of data are available, then the highest value available for each of the score variables should be chosen to produce something that looks like this (the ScoreDate can be dropped):&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;environment$ studyID&lt;SPAN class="s3"&gt;$4.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; StartDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; EndDate &lt;SPAN class="s3"&gt;mmddyy10.&lt;/SPAN&gt;@+&lt;SPAN class="s3"&gt;&lt;STRONG&gt;1&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;daysbwn Movementcode Movecode short_inc count R_Score M_Score S_Score P_Score&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0001 02/06/2008 03/12/2010 765 1 1 0 2&lt;/FONT&gt; 1 &lt;SPAN&gt;5 5&lt;/SPAN&gt;&amp;nbsp;3&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN&gt;HOME&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;0001 03/13/2010 01/01/2015 1755 3 2 0 3 &lt;FONT color="#FF0000"&gt;. . . .&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 01/01/2007 07/31/2007 211 . . 0 1&lt;/FONT&gt;&amp;nbsp;. . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0002 08/01/2007 08/28/2007 27 1 1 1 2&lt;/FONT&gt; 2 3 3 2&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 08/29/2007 02/20/2008 175 3 2 0 3&lt;/FONT&gt; . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;SCHOOL 0002 02/21/2008 03/05/2008 13 1 1 1 4&lt;/FONT&gt; 2 2 2 1&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;HOME 0002 03/06/2008 01/01/2015 2492 3 2 0 5&lt;/FONT&gt; . . . .&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT color="#000000"&gt;Any help to do this properly would be very much appreciated! Thank you in advance.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 21:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326895#M9521</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2017-01-24T21:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the max value from a range of measurements over time</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326896#M9522</link>
      <description>&lt;P&gt;"Each time period" means what exactly?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 23:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326896#M9522</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-23T23:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the max value from a range of measurements over time</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326911#M9523</link>
      <description>&lt;P&gt;I just corrected an error and added an additional explanation to my original post in response to your post. Please let me know if you still have questions. Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 02:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326911#M9523</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2017-01-24T02:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the max value from a range of measurements over time</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326912#M9524</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;This does not solve the problem but may get you on the right path

proc summary data=tempfile max nway;
class environment studyID StartDate;
id environment studyID StartDate;
var R_Score M_Score S_Score P_Score;
output out=max(drop=_type_ _freq_) max=;
run;quit;

proc print data=max; run;



Obs    ENVIRONMENT    STUDYID     STARTDATE    R_SCORE    M_SCORE    S_SCORE    P_SCORE

 1       HOME          0002      2007-01-01       .          .          .          .
 2       HOME          0002      2007-08-29       .          .          .          .
 3       HOME          0002      2008-03-06       .          .          .          .
 4       SCHOOL        0001      2008-02-06       1          5          5          2
 5       SCHOOL        0001      2010-03-13       .          .          .          .
 6       SCHOOL        0002      2007-08-01       2          3          3          2
 7       SCHOOL        0002      2008-02-21       2          2          2          1

You can match back using the compound key plus each max score, or you can just repeat the key with each max score.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 02:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-the-max-value-from-a-range-of-measurements-over/m-p/326912#M9524</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-01-24T02:07:30Z</dc:date>
    </item>
  </channel>
</rss>

