<?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: Retaining only first and last patient visit in dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142963#M38025</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for all the really great answers.&amp;nbsp; I chose Reeza's only because simple is best!&amp;nbsp; I knew when I posted it the answer would be simple but I could not get the correct syntax. Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Mar 2014 14:52:24 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2014-03-14T14:52:24Z</dc:date>
    <item>
      <title>Retaining only first and last patient visit in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142959#M38021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a list of hospital where chart number is the patient identifier and account number is the unique identifier for the visit.&amp;nbsp; I would like to create a data set of just the first visit for the chart number and the last visit for the chart number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input @1&amp;nbsp; chartno $6.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @7&amp;nbsp; acctno&amp;nbsp; $3.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @10 admdate yymmdd8.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @18 sepdate yymmdd8.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @26 postal $6.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;format admdate yymmdd10. sepdate yymmdd10.;&lt;/P&gt;&lt;P&gt;cards;&lt;BR /&gt;1111110012012032920120331N0H2C1&lt;BR /&gt;2222220022012050120120515L4M6X6&lt;BR /&gt;3333330032012060120120607L4N4A8&lt;BR /&gt;1111110042012040220120410N4L1H4&lt;BR /&gt;4444440052012060320120615N4L1S7&lt;BR /&gt;5555550062012053120120603L0L2K0&lt;BR /&gt;2222220072012070120120713L4M6X6&lt;BR /&gt;2222220082012072020120725L9Y2M7&lt;BR /&gt;4444440092012081320120817N4L1S7&lt;BR /&gt;3333330102012061520120621L4N4A8&lt;BR /&gt;1111110112012110120121130N4L1H4&lt;BR /&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the above for chartno 111111 I want the data set to only include the March 31, 2012 visit and the November 30, 2012 visit.&amp;nbsp; Any assistance greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142959#M38021</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2014-03-13T15:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only first and last patient visit in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142960#M38022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First/Last processing should work for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by chartno;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if first.chartno or last.chartno;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 16:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142960#M38022</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-13T16:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only first and last patient visit in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142961#M38023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if I'm missing the problem here. Sort by chartno and date, set with by statement and use first. and last. variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by chartno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; admdate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data FirstAndLast;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by chartno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; admdate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if&amp;nbsp;&amp;nbsp;&amp;nbsp; first.chartno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or last.chartno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 16:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142961#M38023</guid>
      <dc:creator>cu8sfan</dc:creator>
      <dc:date>2014-03-13T16:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only first and last patient visit in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142962#M38024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select chartno, min( admdate) as FirstVisit format=yymmdd10., max(admdate) as LastVisit format=yymmdd10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by chartno;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142962#M38024</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-03-13T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only first and last patient visit in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142963#M38025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for all the really great answers.&amp;nbsp; I chose Reeza's only because simple is best!&amp;nbsp; I knew when I posted it the answer would be simple but I could not get the correct syntax. Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 14:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retaining-only-first-and-last-patient-visit-in-dataset/m-p/142963#M38025</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2014-03-14T14:52:24Z</dc:date>
    </item>
  </channel>
</rss>

