<?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 How do I bracket time periods using dates of events within a confined study period? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282792#M8064</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing a study where I look at how subjects move between two different environments (e.g. hospital and home) over time. All dates that correspond to an admission to the hospital are indicated by time=0, and dates that correspond to released from the hospital&amp;nbsp;are indicated by time=1 (so the value of the time variable alternates&amp;nbsp;between 0 and 1 for each row).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also a variable "period" that represents the order of these events for each subject.&lt;/P&gt;
&lt;P&gt;If someone moves from the hospital to the home and then back to the hospital, they will&amp;nbsp;have time=0, 1, and then 0 again, and period= 1, 2, then 3.&lt;/P&gt;
&lt;P&gt;Please see the attachment&amp;nbsp;for example of what the data output currently looks like (note that there are subject&amp;nbsp;ID numbers that I have truncated to protect confidentiality).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I would like to use the movement dates to create time periods with a start date and end date.&lt;/STRONG&gt; Taking the first subject, for example, with the following data:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Time Period MovementDate (MvmtDate)&lt;/P&gt;
&lt;P class="p1"&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2007&lt;/P&gt;
&lt;P class="p1"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/01/2008&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;My research study period is 01/01/2007 - 12/31/2014. I would like to transform this subject's data into the following (new/manipulated data/variables are bolded):&lt;/P&gt;
&lt;P&gt;Time Period&amp;nbsp;&lt;STRONG&gt;PeriodStartDate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PeriodEndDate&lt;/STRONG&gt; (MvmtDate - 1)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/01/2007&lt;/STRONG&gt; (study start date) &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;01/30/2007&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p1"&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2007 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;04/30/2008&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p1"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/01/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;12/31/2014&lt;/STRONG&gt; (study end date, in this case date of censoring)&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;Do you have any suggestions? I started off by making a separate database to create the first time period (starting 01/01/2007) which I planned to merge in. Then I thought I could create two separate databases to get start and end dates (e.g. 01/31/2007 and 04/30/2008) and merge together into the appropriate rows by offsetting the period variable. But then I realized&amp;nbsp;that creating the last time period (ending with 12/31/2014) might&amp;nbsp;be difficult, and my code is starting to get very complicated. Perhaps there is a way to do this using PROC SQL? Any suggestions would be &lt;U&gt;greatly&lt;/U&gt; appreciated. Thank you!&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12729i05B29C29A8A3D8C5/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Screen Shot 2016-07-07 at 4.17.57 PM.png" title="Screen Shot 2016-07-07 at 4.17.57 PM.png" /&gt;</description>
    <pubDate>Thu, 07 Jul 2016 21:12:55 GMT</pubDate>
    <dc:creator>Kels123</dc:creator>
    <dc:date>2016-07-07T21:12:55Z</dc:date>
    <item>
      <title>How do I bracket time periods using dates of events within a confined study period?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282792#M8064</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing a study where I look at how subjects move between two different environments (e.g. hospital and home) over time. All dates that correspond to an admission to the hospital are indicated by time=0, and dates that correspond to released from the hospital&amp;nbsp;are indicated by time=1 (so the value of the time variable alternates&amp;nbsp;between 0 and 1 for each row).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also a variable "period" that represents the order of these events for each subject.&lt;/P&gt;
&lt;P&gt;If someone moves from the hospital to the home and then back to the hospital, they will&amp;nbsp;have time=0, 1, and then 0 again, and period= 1, 2, then 3.&lt;/P&gt;
&lt;P&gt;Please see the attachment&amp;nbsp;for example of what the data output currently looks like (note that there are subject&amp;nbsp;ID numbers that I have truncated to protect confidentiality).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I would like to use the movement dates to create time periods with a start date and end date.&lt;/STRONG&gt; Taking the first subject, for example, with the following data:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Time Period MovementDate (MvmtDate)&lt;/P&gt;
&lt;P class="p1"&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2007&lt;/P&gt;
&lt;P class="p1"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/01/2008&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;My research study period is 01/01/2007 - 12/31/2014. I would like to transform this subject's data into the following (new/manipulated data/variables are bolded):&lt;/P&gt;
&lt;P&gt;Time Period&amp;nbsp;&lt;STRONG&gt;PeriodStartDate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PeriodEndDate&lt;/STRONG&gt; (MvmtDate - 1)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/01/2007&lt;/STRONG&gt; (study start date) &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;01/30/2007&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p1"&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2007 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;04/30/2008&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p1"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/01/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;12/31/2014&lt;/STRONG&gt; (study end date, in this case date of censoring)&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;Do you have any suggestions? I started off by making a separate database to create the first time period (starting 01/01/2007) which I planned to merge in. Then I thought I could create two separate databases to get start and end dates (e.g. 01/31/2007 and 04/30/2008) and merge together into the appropriate rows by offsetting the period variable. But then I realized&amp;nbsp;that creating the last time period (ending with 12/31/2014) might&amp;nbsp;be difficult, and my code is starting to get very complicated. Perhaps there is a way to do this using PROC SQL? Any suggestions would be &lt;U&gt;greatly&lt;/U&gt; appreciated. Thank you!&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12729i05B29C29A8A3D8C5/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Screen Shot 2016-07-07 at 4.17.57 PM.png" title="Screen Shot 2016-07-07 at 4.17.57 PM.png" /&gt;</description>
      <pubDate>Thu, 07 Jul 2016 21:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282792#M8064</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2016-07-07T21:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I bracket time periods using dates of events within a confined study period?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282804#M8066</link>
      <description>&lt;P&gt;Please post some sample data, fake data is fine, but in your post vs as an attachment and as text not an image. Providing an image means we'd have to type out the data and I won't do that. Make sure to include several use cases that you're likely to encounter and expected output.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 21:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282804#M8066</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-07T21:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I bracket time periods using dates of events within a confined study period?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282813#M8067</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry about that. As requested, here is some fake sample data that&amp;nbsp;represent multiple different possible scenarios:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;Obs ParticipantID Time Period MvmtDate&lt;/P&gt;&lt;P class="p1"&gt;1 00001 0 1 01/31/2007&lt;/P&gt;&lt;P class="p1"&gt;2 00001 1 2 05/01/2008&lt;/P&gt;&lt;P class="p1"&gt;3 00002&amp;nbsp;0 1 06/01/2012&lt;/P&gt;&lt;P class="p1"&gt;4 00002 1 2 05/24/2013&lt;/P&gt;&lt;P class="p1"&gt;5 00003 1 1 02/16/2007&lt;/P&gt;&lt;P class="p1"&gt;6 00003 0 2 05/06/2010&lt;/P&gt;&lt;P class="p1"&gt;7 00003 1 3 08/19/2010&lt;/P&gt;&lt;P class="p1"&gt;8 00004 0 1 06/15/2007&lt;/P&gt;&lt;P class="p1"&gt;9 00004 1 2 06/21/2008&lt;/P&gt;&lt;P class="p1"&gt;10 00005 0 1 04/27/2007&lt;/P&gt;&lt;P class="p1"&gt;11 00005 1 2 11/07/2008&lt;/P&gt;&lt;P class="p1"&gt;12 00006 0 1 03/15/2007&lt;/P&gt;&lt;P class="p1"&gt;13 00006 1 2 06/20/2007&lt;/P&gt;&lt;P class="p1"&gt;14 00007 0 1 08/24/2015&lt;/P&gt;&lt;P class="p1"&gt;15 00008 0 1 04/17/2007&lt;/P&gt;&lt;P class="p1"&gt;16 00008 1 2 04/19/2007&lt;/P&gt;&lt;P class="p1"&gt;17 00009 0 1 05/10/2007&lt;/P&gt;&lt;P class="p1"&gt;18 00009 1 2 08/03/2007&lt;/P&gt;&lt;P class="p1"&gt;19 00010 0 1 07/31/2007&lt;/P&gt;&lt;P class="p1"&gt;20&amp;nbsp;&lt;SPAN&gt;00010&lt;/SPAN&gt; 1 2 08/28/2007&lt;/P&gt;&lt;P class="p1"&gt;21&amp;nbsp;&lt;SPAN&gt;00010&lt;/SPAN&gt; 0 3 02/20/2008&lt;/P&gt;&lt;P class="p1"&gt;22&amp;nbsp;&lt;SPAN&gt;00010&lt;/SPAN&gt; 1 4 03/05/2008&lt;/P&gt;&lt;P class="p1"&gt;23 00011 0 1 02/05/2008&lt;/P&gt;&lt;P class="p1"&gt;24 00011 1 2 03/12/2010&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 21:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-bracket-time-periods-using-dates-of-events-within-a/m-p/282813#M8067</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2016-07-07T21:40:37Z</dc:date>
    </item>
  </channel>
</rss>

