<?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: Proc sql selecting most recent date depending on a second variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445554#M111665</link>
    <description>&lt;P&gt;And another approach if I understand the question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data =master nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class Recipient_Last_Name Recipient_First_Name Drug_Name&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var&amp;nbsp; Date_Dispensed_n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=want (drop=_type_ _freq_) max=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which assumes that the date variable is an actual SAS date value.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Mar 2018 17:33:05 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-14T17:33:05Z</dc:date>
    <item>
      <title>Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445534#M111653</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with pharmaceutical prescription records and I am trying to create an output that includes only the most recent prescription for each drug for each person. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/P&gt;&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/P&gt;&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/P&gt;&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/P&gt;&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the resulting table to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Right now I am using the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = master ;&lt;BR /&gt;by Recipient_Last_Name Recipient_First_Name Date_Dispensed_n descending Drug_Name ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;create table final as&lt;BR /&gt;select *&lt;BR /&gt;from blaine.master&lt;BR /&gt;group by Recipient_Last_Name&lt;BR /&gt;having Date_Dispensed_n = max(Date_Dispensed_n) ;&lt;BR /&gt;quit ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me the most recent date for each last name, but I need the most recent date for EACH DRUG associated with a person.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I.e. the code above gives me this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(need to somehow get the most recent prescriptions of other drugs in there)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;any help would be appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445534#M111653</guid>
      <dc:creator>v2murthy</dc:creator>
      <dc:date>2018-03-14T16:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445538#M111655</link>
      <description>&lt;P&gt;Do you have to use SQL?&lt;/P&gt;
&lt;P&gt;A data step does this very easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by id drug date;
run;

data want;
set have;
by ID drug date;
if last.drug;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/199093"&gt;@v2murthy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with pharmaceutical prescription records and I am trying to create an output that includes only the most recent prescription for each drug for each person. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the resulting table to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Right now I am using the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data = blaine.master ;&lt;BR /&gt;by Recipient_Last_Name Recipient_First_Name Date_Dispensed_n descending Drug_Name ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;BR /&gt;create table final as&lt;BR /&gt;select *&lt;BR /&gt;from blaine.master&lt;BR /&gt;group by Recipient_Last_Name&lt;BR /&gt;having Date_Dispensed_n = max(Date_Dispensed_n) ;&lt;BR /&gt;quit ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives me the most recent date for each last name, but I need the most recent date for EACH DRUG associated with a person.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e. the code above gives me this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(need to somehow get the most recent prescriptions of other drugs in there)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;any help would be appreciated!&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445538#M111655</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-14T16:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445539#M111656</link>
      <description>&lt;P&gt;slight correction in your group by:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Recipient_First_Name $ Recipient_Last_Name $ drug_name $ Date_Dispensed_n :mmddyy10.;
format Date_Dispensed_n mmddyy10.;
datalines;
John smith     adderall     12/28/17
John smith     adderall     12/21/17
John smith     oxycodone 11/14/17
jane doe        adderall       2/14/18
jane doe        oxycodone  1/10/18
jane doe        adderall       12/21/17
;

proc sql;
create table want as
select *
from have
group by Recipient_Last_Name,drug_name
having Date_Dispensed_n = max(Date_Dispensed_n) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445539#M111656</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-14T16:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445541#M111657</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by name drug date;
run;
data want;
    set have;
    by name drug;
    if last.drug then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445541#M111657</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-14T16:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445546#M111659</link>
      <description>&lt;P&gt;Your edits do not change the question or answer significantly except for the explicit variable names. The approach is the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, we don't necessarily see edits so it's best to post as a response or note that you've edited your question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/199093"&gt;@v2murthy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with pharmaceutical prescription records and I am trying to create an output that includes only the most recent prescription for each drug for each person. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;
&lt;P&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/P&gt;
&lt;P&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12/21/17&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the resulting table to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;oxycodone 11/14/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oxycodone&amp;nbsp; 1/10/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Right now I am using the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data = master ;&lt;BR /&gt;by Recipient_Last_Name Recipient_First_Name Date_Dispensed_n descending Drug_Name ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;BR /&gt;create table final as&lt;BR /&gt;select *&lt;BR /&gt;from blaine.master&lt;BR /&gt;group by Recipient_Last_Name&lt;BR /&gt;having Date_Dispensed_n = max(Date_Dispensed_n) ;&lt;BR /&gt;quit ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives me the most recent date for each last name, but I need the most recent date for EACH DRUG associated with a person.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e. the code above gives me this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;John smith&amp;nbsp; &amp;nbsp; &amp;nbsp;adderall&amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/17&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;jane doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adderall&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/14/18&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(need to somehow get the most recent prescriptions of other drugs in there)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;any help would be appreciated!&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445546#M111659</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-14T17:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445554#M111665</link>
      <description>&lt;P&gt;And another approach if I understand the question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data =master nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class Recipient_Last_Name Recipient_First_Name Drug_Name&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var&amp;nbsp; Date_Dispensed_n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=want (drop=_type_ _freq_) max=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which assumes that the date variable is an actual SAS date value.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445554#M111665</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-14T17:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445580#M111681</link>
      <description>&lt;P&gt;Thank you! I didn't realize you could add a comma to include more than one "group by" variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445580#M111681</guid>
      <dc:creator>v2murthy</dc:creator>
      <dc:date>2018-03-14T18:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445581#M111682</link>
      <description>&lt;P&gt;Thanks for the suggestion. This would be much easier to use next time around. Ended up going with another solution since I had the proc sql code written already.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445581#M111682</guid>
      <dc:creator>v2murthy</dc:creator>
      <dc:date>2018-03-14T18:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445582#M111683</link>
      <description>&lt;P&gt;Hi - just edited to remove part of the dataset name for confidentiality purposes. Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/445582#M111683</guid>
      <dc:creator>v2murthy</dc:creator>
      <dc:date>2018-03-14T18:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql selecting most recent date depending on a second variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/578550#M164093</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; master;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;retain&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name fname lname drug date;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; fname $ lname $ drug: &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date: &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmddyy8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmddyy8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;name=cat(fname,lname,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John smith adderall 12/28/17&lt;/P&gt;&lt;P&gt;John smith adderall 12/21/17&lt;/P&gt;&lt;P&gt;John smith oxycodone 11/14/17&lt;/P&gt;&lt;P&gt;jane doe adderall 2/14/18&lt;/P&gt;&lt;P&gt;jane doe oxycodone 1/10/18&lt;/P&gt;&lt;P&gt;jane doe adderall 12/21/17&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=master;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name drug &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;descending&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; master_result;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; master;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name drug &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;descending&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; first.drug &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-selecting-most-recent-date-depending-on-a-second/m-p/578550#M164093</guid>
      <dc:creator>DMIN</dc:creator>
      <dc:date>2019-08-01T19:45:33Z</dc:date>
    </item>
  </channel>
</rss>

