<?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 Conditionally add a label column based on dates and flags of another dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925568#M41549</link>
    <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following two datasets:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first one contains a full list of dates per ID and an index that indicates if the patient has a comorbidity (1) or not (0). Then, there's another dataset that contains a subset of dates from the first dataset and a RefDate, 1 or 0. What I would like to do is the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each ID:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if the comorbidity in DB1 = 1(!) before or =&amp;nbsp; to the&amp;nbsp;Start_Therapy where in DB2 RefDate = 1 then add an Index in DB1 equal to 1 otherwise the Index should be 0 regardless if in DB1 the comorbidity = 1.&lt;/LI&gt;
&lt;LI&gt;if the comorbidity in DB1 = 0 it should remain 0.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output = DB3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data DB1;
  input ID Start_Therapy Comorbidity;
  format Start_Therapy date9.;
cards;
0001 01OCT2015  1
0001 06DEC2016  1
0001 08NOV2020  1
0002 11JAN2014  0
0002 16JUN2014  0
0002 14MAY2015  1
0002 30JUN2015  1
0002 25FEB2016  0
0003 11SEP2012  0
0003 24AUG2014  1
0003 10DEC2014  1
0004 03JAN2014  0
0004 09FEB2014  1
0004 03AUG2015  1
0004 18MAY2016  0
;


data DB2;
  input ID Start_Therapy  RefDate;
  format Start_Therapy date9.;
cards;
0001 06DEC2016  1
0001 08NOV2020  0
0002 16JUN2014  1
0002 30JUN2015  0
0003 24AUG2014  1
0003 10DEC2014  0
0004 03AUG2015  1
;

data DB3;
  input ID  Start_Therapy  Comorbidity Index;
  format Start_Therapy date9.;
cards;
0001 01OCT2015  1  1
0001 06DEC2016  1  1
0001 08NOV2020  1  0
0002 11JAN2014  0  1
0002 16JUN2014  0  1
0002 14MAY2015  1  0
0002 30JUN2015  1  0
0002 25FEB2016  0  0
0003 11SEP2012  0  0
0003 24AUG2014  1  1
0003 10DEC2014  1  0
0004 03JAN2014  0  0
0004 09FEB2014  1  1
0004 03AUG2015  1  1
0004 18MAY2016  0  0
;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2024 16:37:47 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2024-04-24T16:37:47Z</dc:date>
    <item>
      <title>Conditionally add a label column based on dates and flags of another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925568#M41549</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following two datasets:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first one contains a full list of dates per ID and an index that indicates if the patient has a comorbidity (1) or not (0). Then, there's another dataset that contains a subset of dates from the first dataset and a RefDate, 1 or 0. What I would like to do is the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each ID:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if the comorbidity in DB1 = 1(!) before or =&amp;nbsp; to the&amp;nbsp;Start_Therapy where in DB2 RefDate = 1 then add an Index in DB1 equal to 1 otherwise the Index should be 0 regardless if in DB1 the comorbidity = 1.&lt;/LI&gt;
&lt;LI&gt;if the comorbidity in DB1 = 0 it should remain 0.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output = DB3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data DB1;
  input ID Start_Therapy Comorbidity;
  format Start_Therapy date9.;
cards;
0001 01OCT2015  1
0001 06DEC2016  1
0001 08NOV2020  1
0002 11JAN2014  0
0002 16JUN2014  0
0002 14MAY2015  1
0002 30JUN2015  1
0002 25FEB2016  0
0003 11SEP2012  0
0003 24AUG2014  1
0003 10DEC2014  1
0004 03JAN2014  0
0004 09FEB2014  1
0004 03AUG2015  1
0004 18MAY2016  0
;


data DB2;
  input ID Start_Therapy  RefDate;
  format Start_Therapy date9.;
cards;
0001 06DEC2016  1
0001 08NOV2020  0
0002 16JUN2014  1
0002 30JUN2015  0
0003 24AUG2014  1
0003 10DEC2014  0
0004 03AUG2015  1
;

data DB3;
  input ID  Start_Therapy  Comorbidity Index;
  format Start_Therapy date9.;
cards;
0001 01OCT2015  1  1
0001 06DEC2016  1  1
0001 08NOV2020  1  0
0002 11JAN2014  0  1
0002 16JUN2014  0  1
0002 14MAY2015  1  0
0002 30JUN2015  1  0
0002 25FEB2016  0  0
0003 11SEP2012  0  0
0003 24AUG2014  1  1
0003 10DEC2014  1  0
0004 03JAN2014  0  0
0004 09FEB2014  1  1
0004 03AUG2015  1  1
0004 18MAY2016  0  0
;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 16:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925568#M41549</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-04-24T16:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally add a label based on dates and flags of another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925570#M41550</link>
      <description>&lt;P&gt;Your title talks about creating a level. The rest of your post never mentions creating a label. Please clarify.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925570#M41550</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-24T14:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally add a label based on dates and flags of another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925602#M41551</link>
      <description>I'm sorry. It is intended as a label (new) column/index column</description>
      <pubDate>Wed, 24 Apr 2024 16:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditionally-add-a-label-column-based-on-dates-and-flags-of/m-p/925602#M41551</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-04-24T16:38:27Z</dc:date>
    </item>
  </channel>
</rss>

