<?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 Find the last date for each registration in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331098#M21963</link>
    <description>&lt;P&gt;I have a large dataset that features multiple rows per User. &amp;nbsp;Each row has a date that corresponds to the period where data was collected from the user. &amp;nbsp;If the User stops needing to send data that ends up in this dataset the date column records 'END' rather than a date. &amp;nbsp;I odn't know why, but that's the way it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use a computed column to recode the dates to return the date if there's a date, but if there isn't a date to return the latest date against the appropriate User. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do the CASE WHEN bit, but I don't know how to pick out the MAX date for each User? &amp;nbsp;I'm sure it's really easy, but I've not done it before and I'm struggling to know what to google for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 09:20:55 GMT</pubDate>
    <dc:creator>paulrockliffe</dc:creator>
    <dc:date>2017-02-09T09:20:55Z</dc:date>
    <item>
      <title>Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331098#M21963</link>
      <description>&lt;P&gt;I have a large dataset that features multiple rows per User. &amp;nbsp;Each row has a date that corresponds to the period where data was collected from the user. &amp;nbsp;If the User stops needing to send data that ends up in this dataset the date column records 'END' rather than a date. &amp;nbsp;I odn't know why, but that's the way it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use a computed column to recode the dates to return the date if there's a date, but if there isn't a date to return the latest date against the appropriate User. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do the CASE WHEN bit, but I don't know how to pick out the MAX date for each User? &amp;nbsp;I'm sure it's really easy, but I've not done it before and I'm struggling to know what to google for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 09:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331098#M21963</guid>
      <dc:creator>paulrockliffe</dc:creator>
      <dc:date>2017-02-09T09:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331105#M21964</link>
      <description>&lt;P&gt;can you provide sample input data and ouput you required.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 09:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331105#M21964</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2017-02-09T09:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331112#M21966</link>
      <description>&lt;P&gt;So the "date" variable is of type character and contains either a valid date or the "END" string.&lt;/P&gt;
&lt;P&gt;I'd first convert the date variable into a real SAS date, and for "END" I'd set an artificial high value (9999-12-31).&lt;/P&gt;
&lt;P&gt;Then sort by user and date.&lt;/P&gt;
&lt;P&gt;Then a data step like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
retain keep_date;
if not first.user and date = '31dec9999'd then date = keep_date;
keep_date = date;
drop keep_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is necessary that at least the first entry for a user contains a valid date.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 10:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331112#M21966</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-09T10:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331142#M21972</link>
      <description>&lt;P&gt;Hello, thanks that looks like it should work. &amp;nbsp;I can't follow the SQL well enough to know that it will definitely work, but it looks like a good starting point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've actually solved the problem by creating a second Query Builder that takes only the User ID and the MAX of the associated dates, then joining this table back to the original table. &amp;nbsp;I've then used a CASE WHEN statement to substitute these dates where the date is 'END'.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 12:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331142#M21972</guid>
      <dc:creator>paulrockliffe</dc:creator>
      <dc:date>2017-02-09T12:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331144#M21973</link>
      <description>&lt;P&gt;I am little surprised how this date value is 'END' ..is it character variable in the dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 13:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331144#M21973</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2017-02-09T13:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331145#M21974</link>
      <description>&lt;P&gt;It's data that comes from a legacy system, I've no idea how it ends up that way, or why as the final record would still have a date which is then overwritten. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Presumably someone somewhere in the past didn't specify the ability to record that a record would be the last one and someone else decided it was more important to know that than the date of the record. &amp;nbsp;In the context of what the data is used for and the age of the system I can sort of understand that, though it's not ideal!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 13:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331145#M21974</guid>
      <dc:creator>paulrockliffe</dc:creator>
      <dc:date>2017-02-09T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find the last date for each registration</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331237#M21984</link>
      <description>&lt;P&gt;I don't know how you are reading this data into SAS but if you are using a data step you might consider adjusting the process to use a custom format to handle this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue stoopiddate (upcase)
'END' = '21DEC9999'd
other = [mmddyy10.];
run;

data example;
   informat date stoopiddate.;
   input date;
   format date date9.;
datalines;
01/01/2016
02/02/2016
03/03/2016
end
;
run;&lt;/PRE&gt;
&lt;P&gt;sets the "END" value to a large date. OR use a custom missing such as .E and a format that would display .E as "END". I don't have any clue how you may use the resulting value so either approach may be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-the-last-date-for-each-registration/m-p/331237#M21984</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T16:54:51Z</dc:date>
    </item>
  </channel>
</rss>

