<?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: insert rows that are duplicated using a BY variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552371#M153546</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271169"&gt;@stefaniloran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Inpatient events are determined &lt;STRONG&gt;by admit/discharge dates&lt;/STRONG&gt;. Assume that the&lt;BR /&gt;example is already sorted by the admit date descending.&lt;BR /&gt;&lt;BR /&gt;One idea I just had (thanks to your reply) is to start by defining all the&lt;BR /&gt;INP discharge events in a separate table and then join to the full timeline&lt;BR /&gt;to pick out the top 5 events for that patient_id that occur after the INP&lt;BR /&gt;event...&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And you don't include the dates or and indicator for admit/discharge. So how do we know where to insert based on the values &lt;STRONG&gt;in the data&lt;/STRONG&gt; provided?&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2019 22:17:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-18T22:17:49Z</dc:date>
    <item>
      <title>insert rows that are duplicated using a BY variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552253#M153504</link>
      <description>&lt;P&gt;I have used a data step to create a timeline of patient events. I now want to go back and create a table that records the first 5 events after every inpatient discharge. This will intentionally duplicate rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HAVE&lt;/P&gt;&lt;P&gt;patient_id facility_type facility_id timeline_id position_id&lt;/P&gt;&lt;P&gt;1 INP A 1 1&lt;/P&gt;&lt;P&gt;1 SNF A 2 2&lt;/P&gt;&lt;P&gt;1 HHA A 3 3&lt;/P&gt;&lt;P&gt;1 INP B 4 1&lt;/P&gt;&lt;P&gt;1 HHA B 5 2&lt;/P&gt;&lt;P&gt;1 HOS B 6 3&lt;/P&gt;&lt;P&gt;2 INP A 1 1&lt;/P&gt;&lt;P&gt;2 HHA A 2 2&lt;/P&gt;&lt;P&gt;2 HOS A 3 3&lt;/P&gt;&lt;P&gt;2 INP B 4 1&lt;/P&gt;&lt;P&gt;2 HOM B 5 2&lt;/P&gt;&lt;P&gt;2 HOS B 6 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WANT&lt;/P&gt;&lt;P&gt;patient_id facility_type facility_id timeline_id position_id&lt;/P&gt;&lt;P&gt;1 INP A 1 1&lt;/P&gt;&lt;P&gt;1 SNF A 2 2&lt;/P&gt;&lt;P&gt;1 HHA A 3 3&lt;/P&gt;&lt;P&gt;1 INP A 4 4 /*new row*/&lt;/P&gt;&lt;P&gt;1 HHA A 5 5 /*new row*/&lt;/P&gt;&lt;P&gt;1 HOS A 6 6 /*new row*/&lt;/P&gt;&lt;P&gt;1 INP B 4 1&lt;/P&gt;&lt;P&gt;1 HHA B 5 2&lt;/P&gt;&lt;P&gt;1 HOS B 6 3&lt;/P&gt;&lt;P&gt;2 INP A 1 1&lt;/P&gt;&lt;P&gt;2 HHA A 2 2&lt;/P&gt;&lt;P&gt;2 HOS A 3 3&lt;/P&gt;&lt;P&gt;2 INP A 4 4 /*new row*/&lt;/P&gt;&lt;P&gt;2 HOM A 5 5 /*new row*/&lt;/P&gt;&lt;P&gt;2 HOS A 6 6 /*new row*/&lt;/P&gt;&lt;P&gt;2 INP B 4 1&lt;/P&gt;&lt;P&gt;2 HOM B 5 2&lt;/P&gt;&lt;P&gt;2 HOS B 6 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using version 7.15&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 18:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552253#M153504</guid>
      <dc:creator>stefaniloran</dc:creator>
      <dc:date>2019-04-18T18:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: insert rows that are duplicated using a BY variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552279#M153510</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271169"&gt;@stefaniloran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have used a data step to create a timeline of patient events. I now want to go back and create a table that records the first 5 events after&lt;STRONG&gt; every inpatient discharge&lt;/STRONG&gt;. This will intentionally duplicate rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should provide a rule or values that tell us when an inpatient discharge occurs. It appears that your rule might actually be "insert before value of INP for the variable Facility_type. If not, plus expand as "after" is occurring after different values. And what are the rules for the inserted Facility_type? Your example shows two different sets of inserted facility_type but no description where the values come from.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 19:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552279#M153510</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-18T19:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: insert rows that are duplicated using a BY variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552303#M153517</link>
      <description>Inpatient events are determined by admit/discharge dates. Assume that the&lt;BR /&gt;example is already sorted by the admit date descending.&lt;BR /&gt;&lt;BR /&gt;One idea I just had (thanks to your reply) is to start by defining all the&lt;BR /&gt;INP discharge events in a separate table and then join to the full timeline&lt;BR /&gt;to pick out the top 5 events for that patient_id that occur after the INP&lt;BR /&gt;event...&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Apr 2019 19:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552303#M153517</guid>
      <dc:creator>stefaniloran</dc:creator>
      <dc:date>2019-04-18T19:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: insert rows that are duplicated using a BY variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552371#M153546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271169"&gt;@stefaniloran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Inpatient events are determined &lt;STRONG&gt;by admit/discharge dates&lt;/STRONG&gt;. Assume that the&lt;BR /&gt;example is already sorted by the admit date descending.&lt;BR /&gt;&lt;BR /&gt;One idea I just had (thanks to your reply) is to start by defining all the&lt;BR /&gt;INP discharge events in a separate table and then join to the full timeline&lt;BR /&gt;to pick out the top 5 events for that patient_id that occur after the INP&lt;BR /&gt;event...&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And you don't include the dates or and indicator for admit/discharge. So how do we know where to insert based on the values &lt;STRONG&gt;in the data&lt;/STRONG&gt; provided?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 22:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-rows-that-are-duplicated-using-a-BY-variable/m-p/552371#M153546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-18T22:17:49Z</dc:date>
    </item>
  </channel>
</rss>

