<?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: Finding Two Consecutive Equal Values within Subjects - Long Data Format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51809#M10892</link>
    <description>A programming sequence involving multiple DATA steps as an approach (on sorted observations) should work.  You will need to consider using MERGE to "flag" PID instances that are candidates.  Also, look at using a RETAIN stmt to capture and track your "first date" conditions, as well.&lt;BR /&gt;
&lt;BR /&gt;
Attack the requirements/tasks one at a time, as you develop your SAS application program, considering that along the way you may have some adjustments that need to be made.  Use DATA step diagnostic techniques, such as one or more:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;diag-nn' / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
placed in your program, with "nn" being unique for each instance -- this helps you learn / understand the SAS observation/variable values and condition as the program executes.&lt;BR /&gt;
&lt;BR /&gt;
Lastly, you will find a wealth of information at the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website, including SAS-hosted product documentation and also supplemental technical/conference papers on related topics.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Tue, 07 Jul 2009 16:41:06 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-07-07T16:41:06Z</dc:date>
    <item>
      <title>Finding Two Consecutive Equal Values within Subjects - Long Data Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51808#M10891</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
I have longitudinal clinical data in the long format, where patients get multiple labs over the course of treatment. For example:&lt;BR /&gt;
&lt;BR /&gt;
PID    TEST_DATE   RESULT&lt;BR /&gt;
1        02JUN2005     399&lt;BR /&gt;
1        11SEP2005    412 &lt;BR /&gt;
1        04DEC2005    1002&lt;BR /&gt;
1        02FEB2006     2700&lt;BR /&gt;
2        18FEB2007     53&lt;BR /&gt;
2        09MAR2007    102&lt;BR /&gt;
&lt;BR /&gt;
I need to find patients with two or more consecutive RESULT values greater than a threshold, for example, 1000. These patients would be considered to failed treatment. I created a variable indicating results &amp;gt;=1000 so that the data looks like:&lt;BR /&gt;
&lt;BR /&gt;
PID    TEST_DATE   RESULT     X1000&lt;BR /&gt;
1        02JUN2005     399           0&lt;BR /&gt;
1        11SEP2005    412            0&lt;BR /&gt;
1        04DEC2005    1002         1&lt;BR /&gt;
1        02FEB2006     2700         1&lt;BR /&gt;
2        18FEB2007     53             0&lt;BR /&gt;
2        09MAR2007    102            0&lt;BR /&gt;
&lt;BR /&gt;
I sorted by PID and TEST_DATE and created a new data set by PID, but I am stuck on what to do next. Here patient 1 is a failure. I need to (1) create a variable identifying patients that experienced treatment failure; and (2) create another variable with the first date defining failure for each patient that failed. Here, for patient 1 the date of failure would be 04DEC2005.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 07 Jul 2009 14:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51808#M10891</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-07T14:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Two Consecutive Equal Values within Subjects - Long Data Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51809#M10892</link>
      <description>A programming sequence involving multiple DATA steps as an approach (on sorted observations) should work.  You will need to consider using MERGE to "flag" PID instances that are candidates.  Also, look at using a RETAIN stmt to capture and track your "first date" conditions, as well.&lt;BR /&gt;
&lt;BR /&gt;
Attack the requirements/tasks one at a time, as you develop your SAS application program, considering that along the way you may have some adjustments that need to be made.  Use DATA step diagnostic techniques, such as one or more:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;diag-nn' / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
placed in your program, with "nn" being unique for each instance -- this helps you learn / understand the SAS observation/variable values and condition as the program executes.&lt;BR /&gt;
&lt;BR /&gt;
Lastly, you will find a wealth of information at the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website, including SAS-hosted product documentation and also supplemental technical/conference papers on related topics.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 07 Jul 2009 16:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51809#M10892</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-07T16:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Two Consecutive Equal Values within Subjects - Long Data Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51810#M10893</link>
      <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
This would be easily done, by retaining the previous observation (and comparing with the current one) of the sorted dataset.&lt;BR /&gt;
&lt;BR /&gt;
Check the online documention of the RETAIN statement here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
See also some more reading about retaining values:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001310768.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001310768.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Tue, 07 Jul 2009 17:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Two-Consecutive-Equal-Values-within-Subjects-Long-Data/m-p/51810#M10893</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-07-07T17:00:28Z</dc:date>
    </item>
  </channel>
</rss>

