<?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: How do I keep the first observation conditioned upon 2 variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306468#M65521</link>
    <description>&lt;P&gt;Sorry, I need the first of the drug for each unique patient ID. &amp;nbsp;Does your method still work with that requirement?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2016 22:18:05 GMT</pubDate>
    <dc:creator>cbatzi01</dc:creator>
    <dc:date>2016-10-21T22:18:05Z</dc:date>
    <item>
      <title>How do I keep the first observation conditioned upon 2 variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306461#M65519</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have pharmacy claims data. &amp;nbsp;I would like to keep the first record for each patient and each drug based on fill date. My data look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patid Drug Fill_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Normally, if I was interested in only 1 drug, i would only keep those records, and then &amp;nbsp;I would sort by&amp;nbsp;patid and fill_date, then do something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=have; by patid drug fill_date; run;&lt;/P&gt;&lt;P&gt;data want;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;by patid&lt;/P&gt;&lt;P&gt;if first.patid=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But since I need the first patid AND&amp;nbsp;drug, that will not work. &amp;nbsp;How would this be done if I sorted by patid, drug, and fill_date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 22:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306461#M65519</guid>
      <dc:creator>cbatzi01</dc:creator>
      <dc:date>2016-10-21T22:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep the first observation conditioned upon 2 variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306464#M65520</link>
      <description>&lt;P&gt;You want each each new instance of drug in this case, so change your FIRST to be relative to the drug variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.drug;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure your BY statement has at least both variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 22:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306464#M65520</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-21T22:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep the first observation conditioned upon 2 variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306468#M65521</link>
      <description>&lt;P&gt;Sorry, I need the first of the drug for each unique patient ID. &amp;nbsp;Does your method still work with that requirement?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 22:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306468#M65521</guid>
      <dc:creator>cbatzi01</dc:creator>
      <dc:date>2016-10-21T22:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep the first observation conditioned upon 2 variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306470#M65522</link>
      <description>&lt;P&gt;Try it and let me know.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 22:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-the-first-observation-conditioned-upon-2-variables/m-p/306470#M65522</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-21T22:23:25Z</dc:date>
    </item>
  </channel>
</rss>

