<?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: Creating lower and upper bounds for interval censoring in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11003#M977</link>
    <description>&amp;gt; &lt;BR /&gt;
&amp;gt; I'm looking for a way to calculate the lower and&lt;BR /&gt;
&amp;gt; upper bound for each point change.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Thanks in advance!&lt;BR /&gt;
&lt;BR /&gt;
the sophisticated subject seemed out of my range of knowledge, but..&lt;BR /&gt;
it seems stataDM just seeks latest and earliest time values as an ID moves from one "point" to the next &lt;BR /&gt;
That looks like an eaasy challenge for data step handling of retain and/or lag()/dif() functions and by-grouop processing, using a do loop with last.ID to collect info &lt;BR /&gt;
For example :assuming "point" is numeric[pre]data changes ;&lt;BR /&gt;
   do /* loop over rows for an ID */ until( last.ID) ;&lt;BR /&gt;
      set stataDM.data ;&lt;BR /&gt;
      by ID ;&lt;BR /&gt;
      interval = dif( time) ;&lt;BR /&gt;
      if dif( point ) then /* have change in point */ do ;&lt;BR /&gt;
         if not first.ID then output ;&lt;BR /&gt;
         last_point= point ;&lt;BR /&gt;
      end ;&lt;BR /&gt;
      last_time= time ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
run ;[/pre]&lt;BR /&gt;
The output will have an entry for each change of "point" for an ID with extra columns INTERVAL, LAST_POINT and LAST_TIME, which I think should provide what is needed.&lt;BR /&gt;
Then in addition to what appeared to be asked for&lt;BR /&gt;
&amp;gt; change.  The changes I want to look at are 2 to 3, 3&lt;BR /&gt;
&amp;gt; to 4, 4 to 5, 5 to 6, 6 to 7.  I need the lower and&lt;BR /&gt;
&lt;BR /&gt;
it will also provide that 45 interval for ID=2 where POINT changes from 2 to 4 indicated as expected output by this next piece of the original posting&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; So for ID 2, I know that the time falls somewhere&lt;BR /&gt;
&amp;gt; between 09:45 and 10:30 (45 minutes).  The bounds&lt;BR /&gt;
&amp;gt; would then be 1-45.</description>
    <pubDate>Tue, 05 Oct 2010 11:28:07 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-10-05T11:28:07Z</dc:date>
    <item>
      <title>Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11002#M976</link>
      <description>I'm having trouble writing a program to define the lower and upper bounds in order to run a bunch of models using interval censoring.  &lt;BR /&gt;
&lt;BR /&gt;
Here are some sample data and what I need to do:&lt;BR /&gt;
&lt;BR /&gt;
id point time&lt;BR /&gt;
1  3      10:20&lt;BR /&gt;
1  4      11:00&lt;BR /&gt;
1  4      11:30&lt;BR /&gt;
1  5      12:15&lt;BR /&gt;
1  5      12:45&lt;BR /&gt;
1  6      13:50&lt;BR /&gt;
1  7      14:30&lt;BR /&gt;
2  2      09:00&lt;BR /&gt;
2  2      09:45&lt;BR /&gt;
2  4      10:30&lt;BR /&gt;
2  5      11:15&lt;BR /&gt;
2  7      12:25&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I want to run several models (which I don't need help with) looking at the time it takes for the points to change.  Since we do not know the exact time, I want to use interval censoring.  Therefore, my goal is the get the possible lower and upper time points for each change.  The changes I want to look at are 2 to 3, 3 to 4, 4 to 5, 5 to 6, 6 to 7.  I need the lower and upper possible time ranges for each of these changes.  The time ranges will be the least possible time it took to change from 2 to 3 and the most possible time it took to change from 2 to 3 (in minutes).&lt;BR /&gt;
&lt;BR /&gt;
So for ID 2, I know that the time falls somewhere between 09:45 and 10:30 (45 minutes).  The bounds would then be 1-45.&lt;BR /&gt;
&lt;BR /&gt;
I'm looking for a way to calculate the lower and upper bound for each point change.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance!</description>
      <pubDate>Mon, 04 Oct 2010 15:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11002#M976</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-10-04T15:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11003#M977</link>
      <description>&amp;gt; &lt;BR /&gt;
&amp;gt; I'm looking for a way to calculate the lower and&lt;BR /&gt;
&amp;gt; upper bound for each point change.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Thanks in advance!&lt;BR /&gt;
&lt;BR /&gt;
the sophisticated subject seemed out of my range of knowledge, but..&lt;BR /&gt;
it seems stataDM just seeks latest and earliest time values as an ID moves from one "point" to the next &lt;BR /&gt;
That looks like an eaasy challenge for data step handling of retain and/or lag()/dif() functions and by-grouop processing, using a do loop with last.ID to collect info &lt;BR /&gt;
For example :assuming "point" is numeric[pre]data changes ;&lt;BR /&gt;
   do /* loop over rows for an ID */ until( last.ID) ;&lt;BR /&gt;
      set stataDM.data ;&lt;BR /&gt;
      by ID ;&lt;BR /&gt;
      interval = dif( time) ;&lt;BR /&gt;
      if dif( point ) then /* have change in point */ do ;&lt;BR /&gt;
         if not first.ID then output ;&lt;BR /&gt;
         last_point= point ;&lt;BR /&gt;
      end ;&lt;BR /&gt;
      last_time= time ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
run ;[/pre]&lt;BR /&gt;
The output will have an entry for each change of "point" for an ID with extra columns INTERVAL, LAST_POINT and LAST_TIME, which I think should provide what is needed.&lt;BR /&gt;
Then in addition to what appeared to be asked for&lt;BR /&gt;
&amp;gt; change.  The changes I want to look at are 2 to 3, 3&lt;BR /&gt;
&amp;gt; to 4, 4 to 5, 5 to 6, 6 to 7.  I need the lower and&lt;BR /&gt;
&lt;BR /&gt;
it will also provide that 45 interval for ID=2 where POINT changes from 2 to 4 indicated as expected output by this next piece of the original posting&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; So for ID 2, I know that the time falls somewhere&lt;BR /&gt;
&amp;gt; between 09:45 and 10:30 (45 minutes).  The bounds&lt;BR /&gt;
&amp;gt; would then be 1-45.</description>
      <pubDate>Tue, 05 Oct 2010 11:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11003#M977</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-10-05T11:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11004#M978</link>
      <description>I have revised this and hope to do this a different way.  Here is the sample data:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
id point time&lt;BR /&gt;
1 3 0&lt;BR /&gt;
1 4 30&lt;BR /&gt;
1 4 60&lt;BR /&gt;
1 5 90&lt;BR /&gt;
1 5 120&lt;BR /&gt;
1 6 150&lt;BR /&gt;
1 7 210&lt;BR /&gt;
2 2 0&lt;BR /&gt;
2 2 60&lt;BR /&gt;
2 4 120&lt;BR /&gt;
2 5 180&lt;BR /&gt;
2 7 210&lt;BR /&gt;
&lt;BR /&gt;
So what I actually need to get using sample id 2, if I want to calculate the min and max time to go from 4 to 5 it would take [60-120] to get to 4 and [120-180] to get to 5.  So, the minimum time would be 120-120=0 and maximum would be 180-60=120.  My lower bound would be 0 and the upper bound would be 120.  &lt;BR /&gt;
&lt;BR /&gt;
Any thoughts on how to calculate this for each interval in SAS?</description>
      <pubDate>Wed, 06 Oct 2010 14:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11004#M978</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-10-06T14:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11005#M979</link>
      <description>Suggest the OP start with the SAS code piece replied from Peter.C, after digesting what it is doing - then come back to the forum if additional questions exist.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 06 Oct 2010 15:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11005#M979</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-06T15:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11006#M980</link>
      <description>Well, I've completely changed what I need to do, so the code Peter suggested will not work for me.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the suggestion.</description>
      <pubDate>Wed, 06 Oct 2010 15:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11006#M980</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-10-06T15:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11007#M981</link>
      <description>The SAS programming fundamentals are pertinent which you can use and still relate to your objective, I would say - FIRST.&lt;SOME_BY_VARNAME&gt;  and likely LAST.&lt;SOME_BY_VARNAME&gt; to correlate related SAS variable values, capturing TIME and then deriving a interval time measurement.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/SOME_BY_VARNAME&gt;&lt;/SOME_BY_VARNAME&gt;</description>
      <pubDate>Wed, 06 Oct 2010 15:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11007#M981</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-06T15:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating lower and upper bounds for interval censoring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11008#M982</link>
      <description>Thank you to Peter and Scott for your help.  You both led me in the right direction.  I ended up using arrays, but your suggestions helped me to get it right.</description>
      <pubDate>Thu, 14 Oct 2010 21:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-lower-and-upper-bounds-for-interval-censoring/m-p/11008#M982</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-10-14T21:40:38Z</dc:date>
    </item>
  </channel>
</rss>

