<?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 Dates manipulation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875286#M345843</link>
    <description>&lt;P&gt;Starting with the dataset below, we need to identify the index encounter, which is the encounter_date closest to the start_date.&lt;BR /&gt;Encounter_date may be up to two weeks prior to intake survey date(start_Date) through 1 week after it&lt;BR /&gt;We also need to apply a washout period. To qualify as an index encounter, there must be no other encounters within 183 days prior to the 2 week grace period, up to two weeks before the index period.&lt;/P&gt;&lt;P&gt;Person_ID Encoured_Date Start_Date&lt;BR /&gt;00006A7087 10/7/2021 4/5/2022&lt;BR /&gt;00006A7087 11/5/2021 4/5/2022&lt;BR /&gt;00006A7087 11/15/2021 4/5/2022&lt;BR /&gt;00006A7087 12/2/2021 4/5/2022&lt;BR /&gt;00006A7087 12/14/2021 4/5/2022&lt;BR /&gt;00006A7087 12/21/2021 4/5/2022&lt;BR /&gt;00006A7087 1/3/2022 4/5/2022&lt;BR /&gt;00006A7087 1/18/2022 4/5/2022&lt;BR /&gt;00006A7087 1/25/2022 4/5/2022&lt;BR /&gt;00006A7087 2/4/2022 4/5/2022&lt;BR /&gt;00006A7087 2/8/2022 4/5/2022&lt;BR /&gt;00006A7087 2/17/2022 4/5/2022&lt;BR /&gt;00006A7087 3/2/2022 4/5/2022&lt;BR /&gt;00006A7087 3/8/2022 4/5/2022&lt;BR /&gt;00006A7087 3/18/2022 4/5/2022&lt;BR /&gt;00006A7087 4/5/2022 4/5/2022&lt;BR /&gt;00006A7087 4/12/2022 4/5/2022&lt;BR /&gt;0000E20E92 1/28/2022 4/5/2022&lt;BR /&gt;0000E20E92 3/22/2022 4/5/2022&lt;BR /&gt;0000E20E92 4/5/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/3/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/17/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/31/2022 4/5/2022&lt;BR /&gt;0000E20E92 7/15/2022 4/5/2022&lt;BR /&gt;0000E20E92 8/9/2022 4/5/2022&lt;BR /&gt;0000E20E92 10/19/2022 4/5/2022&lt;BR /&gt;0000E20E92 11/30/2022 4/5/2022&lt;BR /&gt;I know how to go 1 week forward and two weeks backward using the intnx function. I however don'w know about how to construct the washout period part.&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2023 16:43:03 GMT</pubDate>
    <dc:creator>mauri0623</dc:creator>
    <dc:date>2023-05-11T16:43:03Z</dc:date>
    <item>
      <title>Dates manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875286#M345843</link>
      <description>&lt;P&gt;Starting with the dataset below, we need to identify the index encounter, which is the encounter_date closest to the start_date.&lt;BR /&gt;Encounter_date may be up to two weeks prior to intake survey date(start_Date) through 1 week after it&lt;BR /&gt;We also need to apply a washout period. To qualify as an index encounter, there must be no other encounters within 183 days prior to the 2 week grace period, up to two weeks before the index period.&lt;/P&gt;&lt;P&gt;Person_ID Encoured_Date Start_Date&lt;BR /&gt;00006A7087 10/7/2021 4/5/2022&lt;BR /&gt;00006A7087 11/5/2021 4/5/2022&lt;BR /&gt;00006A7087 11/15/2021 4/5/2022&lt;BR /&gt;00006A7087 12/2/2021 4/5/2022&lt;BR /&gt;00006A7087 12/14/2021 4/5/2022&lt;BR /&gt;00006A7087 12/21/2021 4/5/2022&lt;BR /&gt;00006A7087 1/3/2022 4/5/2022&lt;BR /&gt;00006A7087 1/18/2022 4/5/2022&lt;BR /&gt;00006A7087 1/25/2022 4/5/2022&lt;BR /&gt;00006A7087 2/4/2022 4/5/2022&lt;BR /&gt;00006A7087 2/8/2022 4/5/2022&lt;BR /&gt;00006A7087 2/17/2022 4/5/2022&lt;BR /&gt;00006A7087 3/2/2022 4/5/2022&lt;BR /&gt;00006A7087 3/8/2022 4/5/2022&lt;BR /&gt;00006A7087 3/18/2022 4/5/2022&lt;BR /&gt;00006A7087 4/5/2022 4/5/2022&lt;BR /&gt;00006A7087 4/12/2022 4/5/2022&lt;BR /&gt;0000E20E92 1/28/2022 4/5/2022&lt;BR /&gt;0000E20E92 3/22/2022 4/5/2022&lt;BR /&gt;0000E20E92 4/5/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/3/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/17/2022 4/5/2022&lt;BR /&gt;0000E20E92 5/31/2022 4/5/2022&lt;BR /&gt;0000E20E92 7/15/2022 4/5/2022&lt;BR /&gt;0000E20E92 8/9/2022 4/5/2022&lt;BR /&gt;0000E20E92 10/19/2022 4/5/2022&lt;BR /&gt;0000E20E92 11/30/2022 4/5/2022&lt;BR /&gt;I know how to go 1 week forward and two weeks backward using the intnx function. I however don'w know about how to construct the washout period part.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 16:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875286#M345843</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2023-05-11T16:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dates manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875414#M345881</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Person_ID :$10. Encounter_date :mmddyy10. Start_Date :mmddyy10.;
format Encounter_date  Start_Date is8601da.;
datalines;
00006A7087 10/7/2021 4/5/2022
00006A7087 11/5/2021 4/5/2022
00006A7087 11/15/2021 4/5/2022
00006A7087 12/2/2021 4/5/2022
00006A7087 12/14/2021 4/5/2022
00006A7087 12/21/2021 4/5/2022
00006A7087 1/3/2022 4/5/2022
00006A7087 1/18/2022 4/5/2022
00006A7087 1/25/2022 4/5/2022
00006A7087 2/4/2022 4/5/2022
00006A7087 2/8/2022 4/5/2022
00006A7087 2/17/2022 4/5/2022
00006A7087 3/2/2022 4/5/2022
00006A7087 3/8/2022 4/5/2022
00006A7087 3/18/2022 4/5/2022
00006A7087 4/5/2022 4/5/2022
00006A7087 4/12/2022 4/5/2022
0000E20E92 1/28/2022 4/5/2022
0000E20E92 3/22/2022 4/5/2022
0000E20E92 4/5/2022 4/5/2022
0000E20E92 5/3/2022 4/5/2022
0000E20E92 5/17/2022 4/5/2022
0000E20E92 5/31/2022 4/5/2022
0000E20E92 7/15/2022 4/5/2022
0000E20E92 8/9/2022 4/5/2022
0000E20E92 10/19/2022 4/5/2022
0000E20E92 11/30/2022 4/5/2022
;
run;

PROC SORT; BY Person_ID Start_Date Encounter_date; RUN;

PROC FORMAT;
value yn
low-&amp;lt;0=' '
0='No'
1-high='Yes';
RUN;

DATA want;
   SET have;
   BY Person_ID Start_Date Encounter_date; 

   /*Encounter_date may be up to two weeks prior to intake survey date(start_Date) through 1 week after it*/
   Survey_low=Start_Date-7;
   Survey_high=Start_Date+7;

   valid_encounter=put(ifn(Survey_low&amp;lt;=Encounter_date&amp;lt;=Survey_high,1,0),yn.);
   /*We also need to apply a washout period. To qualify as an index encounter, 
   there must be no other encounters within 183 days prior to the 2 week grace period, up to two weeks before the index period.*/
   grace_low=Start_Date-14-183;
   grace_high=Start_Date+14;

   retain Encounter_started_in_Range 0;
   if first.Person_ID then Encounter_started_in_Range=0;
   Encounter_started_in_Range=Encounter_started_in_Range+ifn(Survey_low&amp;lt;=Encounter_date&amp;lt;=Survey_high,1,0);
   if Encounter_started_in_Range&amp;gt;1 then washout_failed=1;
   format Survey: grace: is8601da. Encounter_started_in_Range washout_failed yn.;
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2023 09:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875414#M345881</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-05-12T09:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dates manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875458#M345901</link>
      <description>Thank you. I appreciate your time. Obviously, you are a very versed programmer. If it is OK I would like to contact you about this. I still have other part of this that I also need a little help with. I however do not want to be demanding. Just if you have a few minutes that you can spare. Any day or any time will be fine. Hope you have a blast weekend. Thank you again.</description>
      <pubDate>Fri, 12 May 2023 13:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-manipulation/m-p/875458#M345901</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2023-05-12T13:26:18Z</dc:date>
    </item>
  </channel>
</rss>

