<?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: Extraction of data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450369#M113397</link>
    <description>&lt;P&gt;What is the rule that tells us the data contains the correct record?&lt;/P&gt;
&lt;P&gt;Your statement of max/min not working indicates the datatime alone is insufficient (not that the highlighted first record was either a max or min for the identifier). Also "no the status can vary ...to be unworked,clear,worked,etc." does &lt;STRONG&gt;not&lt;/STRONG&gt; tell what the selection rule might be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it by any chance be that you want &amp;nbsp;MAX_of_MAX_of_Version=3 only?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Apr 2018 14:51:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-04-02T14:51:33Z</dc:date>
    <item>
      <title>Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450345#M113392</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Am looking for the highlighted data to be extracted for the following data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Identifier_LHS MAX_of_Date_Loaded_LHS Status_LHS Work_Status_LHS MAX_of_MAX_of_Version&lt;BR /&gt;153553 24MAR18:18:31:58 Clear Unworked 1&lt;BR /&gt;153553 24MAR18:18:32:16 Clear Unworked 2&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;153553 24MAR18:18:32:17 Clear Unworked 3&lt;/FONT&gt;&lt;BR /&gt;153553 24MAR18:18:32:20 Clear Worked 4&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 2&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;14297488 28MAR18:16:39:42 Suspect Unworked 3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Tried using the max of date and max of version ...but not getting the desired o/p&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 13:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450345#M113392</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-02T13:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450348#M113393</link>
      <description>&lt;P&gt;sounds like basic sql exercise&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Identifier_LHS MAX_of_Date_Loaded_LHS :datetime20. Status_LHS $ Work_Status_LHS :$15. MAX_of_MAX_of_Version;
format MAX_of_Date_Loaded_LHS datetime20.;
datalines;
153553 24MAR18:18:31:58 Clear Unworked 1
153553 24MAR18:18:32:16 Clear Unworked 2
153553 24MAR18:18:32:17 Clear Unworked 3
153553 24MAR18:18:32:20 Clear Worked 4
14297488 27FEB18:16:56:53 Suspect Worked 2
14297488 28MAR18:16:39:42 Suspect Unworked 3
;

proc sql;
create table want as
select *
from have
where Work_Status_LHS='Unworked'
group by Identifier_LHS
having MAX_of_Date_Loaded_LHS=max(MAX_of_Date_Loaded_LHS);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Apr 2018 13:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450348#M113393</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-02T13:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450363#M113394</link>
      <description>no the status can vary ...to be unworked,clear,worked,etc.&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Apr 2018 14:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450363#M113394</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-02T14:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450369#M113397</link>
      <description>&lt;P&gt;What is the rule that tells us the data contains the correct record?&lt;/P&gt;
&lt;P&gt;Your statement of max/min not working indicates the datatime alone is insufficient (not that the highlighted first record was either a max or min for the identifier). Also "no the status can vary ...to be unworked,clear,worked,etc." does &lt;STRONG&gt;not&lt;/STRONG&gt; tell what the selection rule might be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it by any chance be that you want &amp;nbsp;MAX_of_MAX_of_Version=3 only?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 14:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450369#M113397</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-02T14:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450513#M113428</link>
      <description>&lt;P&gt;Identifier_LHS Date_Loaded_LHS Status_LHS Work_Status_LHS MAX_of_Version Calculation&lt;BR /&gt;153553 24MAR18:18:32:16 Clear Unworked 4 1&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;153553 24MAR18:18:32:20 Clear Worked 4 1&lt;/FONT&gt;&lt;BR /&gt;153553 24MAR18:18:32:17 Clear Unworked 4 1&lt;BR /&gt;153553 24MAR18:18:31:58 Clear Unworked 4 1&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;153553 24MAR18:18:32:20 Clear Worked 4 1&lt;/FONT&gt;&lt;BR /&gt;153553 24MAR18:18:32:17 Clear Unworked 4 1&lt;BR /&gt;153553 24MAR18:18:32:16 Clear Unworked 4 1&lt;BR /&gt;153553 24MAR18:18:31:58 Clear Unworked 4 1&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 4 1&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;14297488 28MAR18:16:39:42 Suspect Unworked 4 0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want to fetch the latest record with latest date and version is greater max.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but there are cases like record highlighted in blue where the date and time are the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;so after using the max function for date and version it dose not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 03:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450513#M113428</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T03:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450642#M113485</link>
      <description>&lt;P&gt;why not just apply a simple distinct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Identifier_LHS Date_Loaded_LHS :datetime20. Status_LHS $ Work_Status_LHS :$15. MAX_of_Version Calculation;
format Date_Loaded_LHS datetime20.;
datalines;
153553 24MAR18:18:32:16 Clear Unworked 4 1
153553 24MAR18:18:32:20 Clear Worked 4 1
153553 24MAR18:18:32:17 Clear Unworked 4 1
153553 24MAR18:18:31:58 Clear Unworked 4 1
153553 24MAR18:18:32:20 Clear Worked 4 1
153553 24MAR18:18:32:17 Clear Unworked 4 1
153553 24MAR18:18:32:16 Clear Unworked 4 1
153553 24MAR18:18:31:58 Clear Unworked 4 1
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 27FEB18:16:56:53 Suspect Worked 4 1
14297488 28MAR18:16:39:42 Suspect Unworked 4 0
;

proc sql;
create table want as
select distinct Identifier_LHS ,Date_Loaded_LHS ,Status_LHS, Work_Status_LHS ,MAX_of_Version ,Calculation
from have
group by Identifier_LHS
having Date_Loaded_LHS=max(Date_Loaded_LHS);
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 14:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450642#M113485</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T14:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450651#M113493</link>
      <description>yes even if i apply distinct then i am getting the following output:&lt;BR /&gt;Identifier_LHS MAX_of_Date_Loaded_LHS Status_LHS Work_Status_LHS MAX_of_MAX_of_Version&lt;BR /&gt;153553 24MAR18:18:31:58 Clear Unworked 1&lt;BR /&gt;153553 24MAR18:18:32:16 Clear Unworked 2&lt;BR /&gt;153553 24MAR18:18:32:17 Clear Unworked 3&lt;BR /&gt;153553 24MAR18:18:32:20 Clear Worked 4&lt;BR /&gt;14297488 27FEB18:16:56:53 Suspect Worked 2&lt;BR /&gt;14297488 28MAR18:16:39:42 Suspect Unworked 3&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Apr 2018 14:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450651#M113493</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T14:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450656#M113496</link>
      <description>&lt;P&gt;I tested my code with the sample you gave and it seems to work fine&lt;/P&gt;&lt;P&gt;here is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;113 proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;114 create table want as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;115 select distinct Identifier_LHS ,Date_Loaded_LHS ,Status_LHS,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;115! Work_Status_LHS ,MAX_of_Version ,Calculation&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;116 from have&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;117 group by Identifier_LHS&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;118 having Date_Loaded_LHS=max(Date_Loaded_LHS);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;NOTE: The query requires remerging summary statistics back with the&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;original data.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;NOTE: Table WORK.WANT created, with 2 rows and 6 columns.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;119 quit;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;real time 0.01 seconds&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;cpu time 0.01 seconds&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 14:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450656#M113496</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T14:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450750#M113540</link>
      <description>&lt;P&gt;You apparently want one record per id at latest datetime.&amp;nbsp; Then what if you have this data, with tied records at maximum datetime 24MAR18:18:32:20?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;153553 24MAR18:18:32:20 Clear Unworked 4 1&lt;BR /&gt;153553 24MAR18:18:32:20 Clear Worked&amp;nbsp;&amp;nbsp; 4 1&lt;BR /&gt;153553 24MAR18:18:32:20 Clear Unworked&amp;nbsp;5 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;These records have distinct values in other fields.&amp;nbsp;&amp;nbsp;Then what is your rule for choosing a record?&amp;nbsp; The proc sql "select distinct" approach would yield all three.&amp;nbsp; Is that what you want?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 16:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450750#M113540</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T16:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450937#M113604</link>
      <description>thats what the querry is so we taking max date a max version would help . i guess&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Apr 2018 04:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-data/m-p/450937#M113604</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-04T04:10:07Z</dc:date>
    </item>
  </channel>
</rss>

