<?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 Dataset containing only rows where DATE_DOSE2 is after DATE_DOSE1 by ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934472#M367470</link>
    <description>&lt;P&gt;I have this table. We need to make sure to keep only dates for variable DATE_DOSE2 that occur after DATE_DOSE1 by ID. This is a sample table. The resulting dataset should delete row 4 for ID=A since DATE_DOSE2 happens before DATE_DOSE1. What code do you recommend?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data dsin;
input ID $ SESSION DATE_DOSE2 : mmddyy10. DATE_DOSE1 : mmddyy10.;
format DATE_DOSE2 DATE_DOSE1 mmddyy10.;
datalines;
A 2 02/03/2021 .
A 2 02/04/2021 .
A 2 02/05/2021 .
A 2 01/06/2020 .
A 1 . 02/20/2020
B 2 04/16/2021 .
B 2 04/17/2021 .
B 2 04/18/2021 .
B 1 . 02/21/2020
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 Jul 2024 21:38:20 GMT</pubDate>
    <dc:creator>ANKH1</dc:creator>
    <dc:date>2024-07-02T21:38:20Z</dc:date>
    <item>
      <title>Dataset containing only rows where DATE_DOSE2 is after DATE_DOSE1 by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934472#M367470</link>
      <description>&lt;P&gt;I have this table. We need to make sure to keep only dates for variable DATE_DOSE2 that occur after DATE_DOSE1 by ID. This is a sample table. The resulting dataset should delete row 4 for ID=A since DATE_DOSE2 happens before DATE_DOSE1. What code do you recommend?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data dsin;
input ID $ SESSION DATE_DOSE2 : mmddyy10. DATE_DOSE1 : mmddyy10.;
format DATE_DOSE2 DATE_DOSE1 mmddyy10.;
datalines;
A 2 02/03/2021 .
A 2 02/04/2021 .
A 2 02/05/2021 .
A 2 01/06/2020 .
A 1 . 02/20/2020
B 2 04/16/2021 .
B 2 04/17/2021 .
B 2 04/18/2021 .
B 1 . 02/21/2020
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2024 21:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934472#M367470</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2024-07-02T21:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset containing only rows where DATE_DOSE2 is after DATE_DOSE1 by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934482#M367474</link>
      <description>&lt;P&gt;If your data are sorted by ID, and you only have one non-missing DATE_DOSE1 value per ID, then a simple merge of the non-missing DATE_DOSE2 subset with the non-missing DATE_DOSE1 subset will allow you to use a subsetting IF statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsin;
  input ID $ SESSION DATE_DOSE2 : mmddyy10. DATE_DOSE1 : mmddyy10.;
  format DATE_DOSE2 DATE_DOSE1 mmddyy10.;
datalines;
A 2 02/03/2021 .
A 2 02/04/2021 .
A 2 02/05/2021 .
A 2 01/06/2020 .
A 1 .          02/20/2020
B 2 04/16/2021 .
B 2 04/17/2021 .
B 2 04/18/2021 .
B 1 .          02/21/2020
run;
data want;
  merge dsin (where=(date_dose2^=.) drop=date_dose1)
        dsin (where=(date_dose1^=.) keep=id date_dose1);
  by id;
  if date_dose2&amp;gt;date_dose1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2024 00:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934482#M367474</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-07-03T00:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset containing only rows where DATE_DOSE2 is after DATE_DOSE1 by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934484#M367475</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsin;
  input ID $ SESSION DATE_DOSE2 : mmddyy10. DATE_DOSE1 : mmddyy10.;
  format DATE_DOSE2 DATE_DOSE1 mmddyy10.;
datalines;
A 2 02/03/2021 .
A 2 02/04/2021 .
A 2 02/05/2021 .
A 2 01/06/2020 .
A 1 .          02/20/2020
B 2 04/16/2021 .
B 2 04/17/2021 .
B 2 04/18/2021 .
B 1 .          02/21/2020
;

data want;
do until(last.id);
 set dsin;
 by id;
end;
_DATE_DOSE1=DATE_DOSE1;
do until(last.id);
 set dsin;
 by id;
 if  SESSION=1 or DATE_DOSE2&amp;gt;_DATE_DOSE1 then output;
end;
drop _DATE_DOSE1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2024 01:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934484#M367475</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-03T01:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset containing only rows where DATE_DOSE2 is after DATE_DOSE1 by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934574#M367508</link>
      <description>Thanks!</description>
      <pubDate>Wed, 03 Jul 2024 15:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-containing-only-rows-where-DATE-DOSE2-is-after-DATE/m-p/934574#M367508</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2024-07-03T15:32:56Z</dc:date>
    </item>
  </channel>
</rss>

