<?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 Calculate time by comparing conditions and dates vertically in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989376#M43920</link>
    <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following dataset:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$200. Event:$200. Date :date09.;
    format Date date9.;
cards;
0001 CR    01SEP2024
0001 PR    10OCT2024
0001 CR    15DEC2024
0001 PD    22MAR2025
0001 CR    08AUG2025
0001 PD    20OCT2025
0001 Death 02DEC2025

;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here, for simplicity only one patient is shown but the dataset is made of around 100 patients. This patient I'm showing, resumes all the possible cases. As you can see it has different responses to treatment: the complete response, the partial response, the progressive disease and the death. I have to calculate the difference (in months and I know how to do it) between the date of the first occurring PD and the date of the first occurring event other than PD and death. In this case it should be: 22MAR2025-01SEP2024. In principle I know how to compare values but my difficulty is that the comparison should be done vertically and only vertically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me please?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2026 15:53:08 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2026-06-08T15:53:08Z</dc:date>
    <item>
      <title>Calculate time by comparing conditions and dates vertically</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989376#M43920</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following dataset:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$200. Event:$200. Date :date09.;
    format Date date9.;
cards;
0001 CR    01SEP2024
0001 PR    10OCT2024
0001 CR    15DEC2024
0001 PD    22MAR2025
0001 CR    08AUG2025
0001 PD    20OCT2025
0001 Death 02DEC2025

;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here, for simplicity only one patient is shown but the dataset is made of around 100 patients. This patient I'm showing, resumes all the possible cases. As you can see it has different responses to treatment: the complete response, the partial response, the progressive disease and the death. I have to calculate the difference (in months and I know how to do it) between the date of the first occurring PD and the date of the first occurring event other than PD and death. In this case it should be: 22MAR2025-01SEP2024. In principle I know how to compare values but my difficulty is that the comparison should be done vertically and only vertically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me please?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 15:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989376#M43920</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2026-06-08T15:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time by comparing conditions and dates vertically</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989382#M43921</link>
      <description>&lt;P&gt;I can see from some of your other questions that you're familiar with the RETAIN statement.&amp;nbsp; So in this case, couldn't you calculate start date for each ID, retain it, and then when you come to the first PD record, calculate the difference in dates?&amp;nbsp; Or if you like the double DOW loop approach, that could be used here as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those are just hints.&amp;nbsp; Can you show the code you've tried, and describe what went wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 17:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989382#M43921</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-06-08T17:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time by comparing conditions and dates vertically</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989392#M43922</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;is on the right track. Use the RETAIN statement. Give it a try, show us what you have tried.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it would be &lt;EM&gt;extremely&lt;/EM&gt; helpful if you can show us the desired output for this particular patient. (And hint hint hint, you should ALWAYS show us the desired output in these complex situations, we shouldn't have to ask.)&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 21:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-time-by-comparing-conditions-and-dates-vertically/m-p/989392#M43922</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2026-06-08T21:27:32Z</dc:date>
    </item>
  </channel>
</rss>

