<?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 flagging cases in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/flagging-cases/m-p/281858#M57193</link>
    <description>&lt;P&gt;I have a dataset like below. There are 3 patients that visited the hospital multiple times, whether planned or unplanned. I would like to flag all the cases as planned = 1 once we find the first planned case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tr1;&lt;BR /&gt;input ptid$ day planned;&lt;BR /&gt;cards;&lt;BR /&gt;a 0 0&lt;BR /&gt;a 5 0&lt;BR /&gt;a 10 0&lt;BR /&gt;a 12 1&lt;BR /&gt;a 15 1&lt;BR /&gt;a 20 0&lt;BR /&gt;a 25 0&lt;BR /&gt;a 29 1&lt;BR /&gt;b 0 0&lt;BR /&gt;b 6 0&lt;BR /&gt;b 14 1&lt;BR /&gt;c 0 1&lt;BR /&gt;c 11 0&lt;BR /&gt;c 15 0&lt;BR /&gt;c 19 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have an output as below adding one extra flag. For ear patient (ptid) once it finds the first planed visit, I would like to have all the records after first planned visit as planned visit even if they are unplanned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ptid day planned plflag&lt;BR /&gt;a 0 0 0&lt;BR /&gt;a 5 0 0&lt;BR /&gt;a 10 0 0&lt;BR /&gt;a 12 1 1&lt;BR /&gt;a 15 1 1&lt;BR /&gt;a 20 0 1&lt;BR /&gt;a 25 0 1&lt;BR /&gt;a 29 1 1&lt;BR /&gt;b 0 0 1&lt;BR /&gt;b 6 0 1&lt;BR /&gt;b 14 1 1&lt;BR /&gt;c 0 1 1&lt;BR /&gt;c 11 0 1&lt;BR /&gt;c 15 0 1&lt;/P&gt;</description>
    <pubDate>Sat, 02 Jul 2016 20:12:35 GMT</pubDate>
    <dc:creator>AviS</dc:creator>
    <dc:date>2016-07-02T20:12:35Z</dc:date>
    <item>
      <title>flagging cases</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-cases/m-p/281858#M57193</link>
      <description>&lt;P&gt;I have a dataset like below. There are 3 patients that visited the hospital multiple times, whether planned or unplanned. I would like to flag all the cases as planned = 1 once we find the first planned case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tr1;&lt;BR /&gt;input ptid$ day planned;&lt;BR /&gt;cards;&lt;BR /&gt;a 0 0&lt;BR /&gt;a 5 0&lt;BR /&gt;a 10 0&lt;BR /&gt;a 12 1&lt;BR /&gt;a 15 1&lt;BR /&gt;a 20 0&lt;BR /&gt;a 25 0&lt;BR /&gt;a 29 1&lt;BR /&gt;b 0 0&lt;BR /&gt;b 6 0&lt;BR /&gt;b 14 1&lt;BR /&gt;c 0 1&lt;BR /&gt;c 11 0&lt;BR /&gt;c 15 0&lt;BR /&gt;c 19 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have an output as below adding one extra flag. For ear patient (ptid) once it finds the first planed visit, I would like to have all the records after first planned visit as planned visit even if they are unplanned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ptid day planned plflag&lt;BR /&gt;a 0 0 0&lt;BR /&gt;a 5 0 0&lt;BR /&gt;a 10 0 0&lt;BR /&gt;a 12 1 1&lt;BR /&gt;a 15 1 1&lt;BR /&gt;a 20 0 1&lt;BR /&gt;a 25 0 1&lt;BR /&gt;a 29 1 1&lt;BR /&gt;b 0 0 1&lt;BR /&gt;b 6 0 1&lt;BR /&gt;b 14 1 1&lt;BR /&gt;c 0 1 1&lt;BR /&gt;c 11 0 1&lt;BR /&gt;c 15 0 1&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2016 20:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-cases/m-p/281858#M57193</guid>
      <dc:creator>AviS</dc:creator>
      <dc:date>2016-07-02T20:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: flagging cases</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-cases/m-p/281863#M57195</link>
      <description>&lt;P&gt;Assuming your example is wrong for pationt b :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.ptid);
    set tr1; by ptid;
    plFlag = plFlag or planned;
    output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jul 2016 20:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-cases/m-p/281863#M57195</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-02T20:35:15Z</dc:date>
    </item>
  </channel>
</rss>

