<?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: observation selection based on max value of another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604277#M175170</link>
    <description>&lt;P&gt;I don't understand this. Acc is constand besides one obs?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 20:44:02 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-14T20:44:02Z</dc:date>
    <item>
      <title>observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604274#M175169</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset such that for each value of 'acc', I want to select the row with the highest 'DT' value where flag='Y'. Below is the input dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Form&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;DT&lt;/TD&gt;&lt;TD&gt;acc&lt;/TD&gt;&lt;TD&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60663233&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;01Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699093&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699143&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699213&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699983&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699998&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60700023&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;61120139&lt;/TD&gt;&lt;TD&gt;2317&lt;/TD&gt;&lt;TD&gt;12Nov2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I've come up with so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table abc as
select * 
from sample where flag = 'Y' having dt = max(dt);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this gives me the following output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Form&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;DT&lt;/TD&gt;&lt;TD&gt;acc&lt;/TD&gt;&lt;TD&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;61120139&lt;/TD&gt;&lt;TD&gt;2317&lt;/TD&gt;&lt;TD&gt;12Nov2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm trying to get the following output: I don't need the max value of DT for the entire table, but looking to get the max DT value per acc.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Form&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;DT&lt;/TD&gt;&lt;TD&gt;acc&lt;/TD&gt;&lt;TD&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;60699213&lt;/TD&gt;&lt;TD&gt;2210&lt;/TD&gt;&lt;TD&gt;03Oct2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;61120139&lt;/TD&gt;&lt;TD&gt;2317&lt;/TD&gt;&lt;TD&gt;12Nov2019 0:00:00.000&lt;/TD&gt;&lt;TD&gt;test1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help and time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604274#M175169</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2019-11-14T20:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604277#M175170</link>
      <description>&lt;P&gt;I don't understand this. Acc is constand besides one obs?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604277#M175170</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-14T20:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604278#M175171</link>
      <description>&lt;P&gt;Add a&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;group by acc;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table abc as
select * 
from sample where flag = 'Y' 
group by acc
having dt = max(dt);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604278#M175171</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T20:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604280#M175173</link>
      <description>so diff forms are submitted for a certain 'acc' value on different dates 'dt', hence you see multiple entries with different form values for the same account but on different dates. So I need to look for the most recent form submission for every acc value. hope this provides some context.</description>
      <pubDate>Thu, 14 Nov 2019 20:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604280#M175173</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2019-11-14T20:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604281#M175174</link>
      <description>I tried that earlier, that gives an error:&lt;BR /&gt;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, EQT, EXCEPT,&lt;BR /&gt;GE, GET, GT, GTT, INTERSECT, LE, LET, LT, LTT, NE, NET, NOT, OR, ORDER, OUTER, UNION, ^, ^=, |, ||, ~, ~=.&lt;BR /&gt;&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.</description>
      <pubDate>Thu, 14 Nov 2019 20:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604281#M175174</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2019-11-14T20:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604282#M175175</link>
      <description>nevermind, I was adding group by after having instead of before. This works. Thank you!!</description>
      <pubDate>Thu, 14 Nov 2019 20:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604282#M175175</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2019-11-14T20:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604283#M175176</link>
      <description>&lt;P&gt;If your data are already sorted by ACC:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
  infile datalines missover;
  input Form ID DT :datetime21.3 acc :$5. flag :$1. ;
  format dt datetime24.3;
datalines;
60663233 2210 01Oct2019:0:00:00.000 test Y 
60699093 2210 03Oct2019:0:00:00.000 test   
60699143 2210 03Oct2019:0:00:00.000 test   
60699213 2210 03Oct2019:0:00:00.000 test Y 
60699983 2210 03Oct2019:0:00:00.000 test   
60699998 2210 03Oct2019:0:00:00.000 test   
60700023 2210 03Oct2019:0:00:00.000 test   
61120139 2317 12Nov2019:0:00:00.000 test1 Y 
run;

data want (drop=_:);
  do until (last.acc);
    set abc;
    where flag='Y';
    by acc;
    _maxdt=max(dt,_maxdt);
  end;
  do until (last.acc);
    set abc;
    where flag='Y';
    by acc;
    if dt=_maxdt then put (_all_) (=); *output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program doesn't bother reading in observations unless it has flag='Y'.&amp;nbsp; The &lt;EM&gt;&lt;STRONG&gt;where flag="Y";&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; statements outsource the filtering process to the data engine, so only the qualifyi8ng records are seen by the data step.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604283#M175176</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-14T20:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604284#M175177</link>
      <description>&lt;P&gt;The SQL clauses are as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. SELECT- MUST&lt;/P&gt;
&lt;P&gt;2. FROM-MUST&lt;/P&gt;
&lt;P&gt;3. WHERE (IF ANY)&lt;/P&gt;
&lt;P&gt;4. GROUP BY (IF ANY)&lt;/P&gt;
&lt;P&gt;5. HAVING (IF A GROUPED FILTER IS REQUIRED)&lt;/P&gt;
&lt;P&gt;6. ORDER BY (IF YOU WANT TO ORDER)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Courtesy:&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp; aka prodigy genius stats who corrected me 2 years ago. I took those notes seriously after &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
infile cards truncover;
input Form	ID @21	DT datetime21. acc $	flag $;
format dt datetime20.;
cards;
60663233    2210   	01Oct2019 0:00:00.000	test	Y
60699093	2210	03Oct2019 0:00:00.000	test	 
60699143	2210	03Oct2019 0:00:00.000	test	 
60699213	2210	03Oct2019 0:00:00.000	test	Y
60699983	2210	03Oct2019 0:00:00.000	test	 
60699998	2210	03Oct2019 0:00:00.000	test	 
60700023	2210	03Oct2019 0:00:00.000	test	 
61120139	2317	12Nov2019 0:00:00.000	test1	Y
;

proc sql;
create table abc as
select * 
from have 
where flag = 'Y' 
group by acc
having dt = max(dt);
quit;

proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.ABC" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Form&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DT&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;acc&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;flag&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;60699213&lt;/TD&gt;
&lt;TD class="r data"&gt;2210&lt;/TD&gt;
&lt;TD class="r data"&gt;03OCT2019:00:00:00&lt;/TD&gt;
&lt;TD class="l data"&gt;test&lt;/TD&gt;
&lt;TD class="l data"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;61120139&lt;/TD&gt;
&lt;TD class="r data"&gt;2317&lt;/TD&gt;
&lt;TD class="r data"&gt;12NOV2019:00:00:00&lt;/TD&gt;
&lt;TD class="l data"&gt;test1&lt;/TD&gt;
&lt;TD class="l data"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604284#M175177</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T20:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604285#M175178</link>
      <description>this is excellent piece, I will note it down &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;thank you!</description>
      <pubDate>Thu, 14 Nov 2019 20:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604285#M175178</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2019-11-14T20:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604313#M175192</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265086"&gt;@AJ_Brien&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;A non-SQL way you can approach this with depends on whether your input is sorted by ACC or not. If it is sorted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                             
  input form id dt :datetime18. acc $ flag $ ;                                                                                          
  format dt datetime. ;                                                                                                                 
  cards ;                                                                                                                               
60663233  2210  01Oct2019:00:00:00  test   Y                                                                                            
60699093  2210  03Oct2019:00:00:00  test   .                                                                                            
60699143  2210  03Oct2019:00:00:00  test   .                                                                                            
60699213  2210  03Oct2019:00:00:00  test   Y                                                                                            
60699983  2210  03Oct2019:00:00:00  test   .                                                                                            
60699998  2210  03Oct2019:00:00:00  test   .                                                                                            
60700023  2210  03Oct2019:00:00:00  test   .                                                                                            
61120139  2317  12Nov2019:00:00:00  test1  Y                                                                                            
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data want ;                                                                                                                             
  do until (last.acc) ;                                                                                                                 
    set have (where=(flag="Y")) curobs = _q ;                                                                                           
    by acc ;                                                                                                                            
    if dt &amp;lt; _n_ then continue ;                                                                                                         
    _n_ = dt ;                                                                                                                          
    _s  = _q ;                                                                                                                          
  end ;                                                                                                                                 
  set have point = _s ;                                                                                                                 
run ;               
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it is not sorted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                                                                                                             
  dcl hash h () ;                                                                                                                       
  h.definekey ("acc") ;                                                                                                                 
  h.definedata ("_n_", "_s") ;                                                                                                          
  h.definedone () ;                                                                                                                     
  do until (z) ;                                                                                                                        
    set have curobs = _q end = z ;                                                                                                      
    where flag = "Y" ;                                                                                                                  
    if h.find() ne 0 then call missing (_n_, _s) ;                                                                                      
    if dt &amp;lt;= _n_ then continue ;                                                                                                        
    _n_ = dt ;                                                                                                                          
    _s  = _q ;                                                                                                                          
    h.replace() ;                                                                                                                       
  end ;                                                                                                                                 
  dcl hiter hi ("h") ;                                                                                                                  
  do while (hi.next() = 0) ;                                                                                                            
    set have point = _s ;                                                                                                               
    output ;                                                                                                                            
  end ;                                                                                                                                 
run ;                     
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In both &amp;nbsp;cases, if there's a tie between two "Y" records with the same maximal date, the first occurrence is selected. Note that self-merging SQL offered by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;won't handle this and instead return all the tied records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;PaulD.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604313#M175192</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-11-14T21:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: observation selection based on max value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604323#M175195</link>
      <description>&lt;P&gt;Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp; &amp;nbsp;Yes fully agree and point well taken. Yet another exuberance of "attention to detail". Kudos!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265086"&gt;@AJ_Brien&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My thoughts&amp;nbsp; &amp;amp; &lt;EM&gt;&lt;STRONG&gt;assumptions&lt;/STRONG&gt;&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. if your dataset doesn't have any more variables than the ones listed and the values are truly representative of your real,&lt;STRONG&gt;&lt;EM&gt; select distinct * &lt;/EM&gt;&lt;/STRONG&gt;should handle the duplicates and will pick only instance&lt;EM&gt;.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;2.&amp;nbsp;&lt;/EM&gt;Point 1 essentially means you could have extra records of max dt and relies on this consistency. Strictly speaking, if even FORMNO changes for the same records that tied with the max dates, the &lt;STRONG&gt;select distinct *&lt;/STRONG&gt; will of course fail.&lt;/P&gt;
&lt;P&gt;3. If what Hashman pointed happens to be true, his solution is bullet proof and robust.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hashman's diligence should have opened your eyes too to carefully examine the ties and associated variables in a record. Please make sure you keep note of it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 22:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observation-selection-based-on-max-value-of-another-column/m-p/604323#M175195</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T22:01:44Z</dc:date>
    </item>
  </channel>
</rss>

