<?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: Flag Maximum Encounter Date(s) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/455989#M115451</link>
    <description>&lt;P&gt;To keep several observations, all with the same maximum date, sort in descending order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=aaa;&lt;/P&gt;
&lt;P&gt;by fy fm ppid descending encounter_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it is easy to select all those having the maximum:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by fy fm ppid;&lt;/P&gt;
&lt;P&gt;if first.ppid then max_date = encounter_date;&lt;/P&gt;
&lt;P&gt;retain max_date;&lt;/P&gt;
&lt;P&gt;Max_Enc_Date = (encounter_date = max_date);&lt;/P&gt;
&lt;P&gt;drop max_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Apr 2018 16:28:25 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-04-20T16:28:25Z</dc:date>
    <item>
      <title>Flag Maximum Encounter Date(s)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/455983#M115446</link>
      <description>&lt;P&gt;Hello Everybody!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got a data set and I'm trying to create a variable that will flag the last Encounter_Date for each patient for each fiscal month/fiscal year. They may have multiple encounters on the last Encounter_Date. I'm trying to replicate the results of this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; bbb &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; * &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; aaa&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; fy, fm, ppid&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;having encounter_date = max(encounter_date);&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;quit&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with something like this (I want to keep all records in aaa and flag the max(encounter_date)):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; = aaa; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; FY FM ppid encounter_date; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; bbb;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; aaa;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; FY FM ppid;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; last.ppid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; Max_Enc_Date = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; Max_Enc_Date =&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;Brian&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/455983#M115446</guid>
      <dc:creator>BTAinRVA</dc:creator>
      <dc:date>2018-04-20T16:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Maximum Encounter Date(s)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/455989#M115451</link>
      <description>&lt;P&gt;To keep several observations, all with the same maximum date, sort in descending order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=aaa;&lt;/P&gt;
&lt;P&gt;by fy fm ppid descending encounter_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it is easy to select all those having the maximum:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by fy fm ppid;&lt;/P&gt;
&lt;P&gt;if first.ppid then max_date = encounter_date;&lt;/P&gt;
&lt;P&gt;retain max_date;&lt;/P&gt;
&lt;P&gt;Max_Enc_Date = (encounter_date = max_date);&lt;/P&gt;
&lt;P&gt;drop max_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/455989#M115451</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-20T16:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Maximum Encounter Date(s)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/456002#M115464</link>
      <description>&lt;P&gt;That's Astounding!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Maximum-Encounter-Date-s/m-p/456002#M115464</guid>
      <dc:creator>BTAinRVA</dc:creator>
      <dc:date>2018-04-20T16:55:51Z</dc:date>
    </item>
  </channel>
</rss>

