<?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: Split an observation into two rows and modify them in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507920#M1549</link>
    <description>Thanks! I updated my descriptions. So, hopefully it'll be clear this time.</description>
    <pubDate>Fri, 26 Oct 2018 23:44:02 GMT</pubDate>
    <dc:creator>Alireza_Boloori</dc:creator>
    <dc:date>2018-10-26T23:44:02Z</dc:date>
    <item>
      <title>Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507883#M1534</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data of prescription drug supplies. I want to adjust this data based on a time window of 90 days. Here are what I have and what I want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date_start:yymmdd10. date_stop:yymmdd10. duration increment_start increment_stop;
datalines;
1	1/15/2008	1/30/2008	16	1	1
1	1/31/2008	2/14/2008	15	1	1
1	4/13/2008	5/2/2008	20	1	2
1	5/30/2008	6/29/2008	31	2	2
1	7/7/2008	8/6/2008	31	2	3
2	1/24/2008	2/18/2008	26	1	1
2	2/19/2008	2/19/2008	1	1	1
2	4/21/2008	5/11/2008	21	1	2
2	5/12/2008	5/13/2008	2	2	2
2	7/11/2008	8/3/2008	24	2	3
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input id date_start:yymmdd10. date_stop:yymmdd10. duration increment_start increment_stop;
datalines;
1	1/15/2008	1/30/2008	16	1	1
1	1/31/2008	2/14/2008	15	1	1
1	4/13/2008	4/13/2008	1	1	1
1	4/14/2008	5/2/2008	19	2	2
1	5/30/2008	6/29/2008	31	2	2
1	7/7/2008	7/12/2008	6	2	2
1	7/13/2008	8/6/2008	25	3	3
2	1/24/2008	2/18/2008	26	1	1
2	2/19/2008	2/19/2008	1	1	1
2	4/21/2008	4/22/2008	2	1	1
2	4/23/2008	5/11/2008	19	2	2
2	5/12/2008	5/13/2008	2	2	2
2	7/11/2008	7/21/2008	11	2	2
2	7/22/2008	8/3/2008	13	3	3
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;"date_start" and&amp;nbsp;&lt;SPAN&gt;"date_stop" are the beginning and end of a drug supply for each observation.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;"duration" is the number of days for the corresponding drug supply; i.e., duration =&amp;nbsp;date_stop - date_start&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;For each patient, consider&amp;nbsp;"date_start" for the first observation as the baseline time; e.g., 1/15/2008 is the baseline time for patient 1.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;"increment_start" and "increment_stop" indicate whether the whole drug supply period for each observation is within an increment of 90 days from the baseline time. If these two variables are not equal, that means a part of the drug supply is not within that 90 days. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;So, I have to split that drug supply (time-wise), so that the first part is within the first 90 days, and the second part is within the second 90 days. For example, you can compare row 3 in data have with rows 3-4 in data want.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea or help is much appreciated!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 02:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507883#M1534</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2018-10-27T02:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507888#M1537</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147550"&gt;@Alireza_Boloori&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, for the third observation for ID = 1, the supply of drug is started before day 90, while the end date of supply is after 90 days. So, I had to split that observation into two rows, and also modify each row (e.g., data_start, data_stop, duration, etc.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;In term of the variables shown how do we know that the "&amp;nbsp;supply of drug is started before day 90" and "the end date of supply is after 90&amp;nbsp;". I might guess correctly but the problem should include the variable names used and rules involving the variables. I am guessing that the day_counter variables are involved but it is not explicitly clear which is start or end, similar with the time_window variables.&lt;/P&gt;
&lt;P&gt;There seems to be an implied manipulation of the dates and duration_day variable&amp;nbsp;but that rule is not very clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely know a whole lot about what each of these are because you have been working with them but we have little or not context and it helps if we don't have to guess which what goes where.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 20:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507888#M1537</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-26T20:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507920#M1549</link>
      <description>Thanks! I updated my descriptions. So, hopefully it'll be clear this time.</description>
      <pubDate>Fri, 26 Oct 2018 23:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507920#M1549</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2018-10-26T23:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507923#M1552</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147550"&gt;@Alireza_Boloori&lt;/a&gt;can you please post sample code that you are working with?&lt;/P&gt;&lt;P&gt;what have you tried?&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have a lot listed above with rules that are still unclear based on data that is not present in your sample data due to patient engagement in fulfilling prescriptions or having those prescriptions renewed.&lt;/P&gt;&lt;P&gt;Please post what you have tried in the form of a datastep, SQL query.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 01:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507923#M1552</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-10-27T01:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507935#M1556</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;Thanks. I've made my description simpler and removed unnecessary variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, please find the code that I use for this splitting. It only creates the duplicated row, but I couldn't find any way to modify the variables&amp;nbsp;across the duplicated rows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
output;
if increment_start~= increment_stop then do;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Oct 2018 02:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507935#M1556</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2018-10-27T02:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507944#M1558</link>
      <description>&lt;P&gt;This will also take care of&amp;nbsp;durations longer than 90 days&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
retain is0dt;
set have; by id;
if first.id then is0dt = date_start;
ds = date_stop;
do while (date_start &amp;lt;= ds);
    inc = 1 + intck("day90", is0dt, date_start, "c");
    date_stop = min(ds, intnx("day", is0dt, inc*90-1));
    output;
    date_start = intnx("day", date_stop, 1);
    end;
drop is0dt ds;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 04:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/507944#M1558</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-27T04:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/508005#M1572</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Thank you very much for your help!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 17:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/508005#M1572</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2018-10-27T17:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Split an observation into two rows and modify them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/508011#M1573</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Elegance at best&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Oct 2018 18:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-an-observation-into-two-rows-and-modify-them/m-p/508011#M1573</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-27T18:25:15Z</dc:date>
    </item>
  </channel>
</rss>

