<?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: How to identify obs where date B is up tp 120 days greater than date A in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746409#M234145</link>
    <description>&lt;P&gt;What about B dates smaller than or within 10 days from A?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, SAS dates are counts of days, so you can do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 11 le dateb - datea le 20
then y_n = "Yes";
else if dateb - datea gt 20 then y_n = "No";&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Jun 2021 07:30:09 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-06-08T07:30:09Z</dc:date>
    <item>
      <title>How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746399#M234141</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have patient Id's with Date A and Date B. I am trying to assign 'Yes' to the patients where Date B is 11 to 20 days greater than Date A an 'No' to any Id where Date B&amp;nbsp; is 21 or more days greater than Date A.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y/N&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10May17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25May17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8Nov18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10Dec18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13June17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26June17&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where do I start?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 06:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746399#M234141</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-06-08T06:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746406#M234142</link>
      <description>&lt;P&gt;You start with SAS date valued variables. If your variables are 1) numeric and 2) have format like DATE7. assigned your likely good. If the format is $ anything the first step will be to get the SAS dates using INPUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS dates are number of days since 1Jan1960. So when you are interested in days you can do simple subraction:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;date want;
   set have;
   NewVar = (11 le (dateb -datea) le 20);
run;&lt;/PRE&gt;
&lt;P&gt;Will create a numeric variable valued as 1 when the difference is in the range and 0 otherwise. SAS uses 1 as true and 0 as false and is much more flexible than assigning character Y N values. If you must "see" Y or N in a report it takes about 3 minutes or less to write a custom format to display the numeric 1 as 'Y', 'Yes', 'True' or "You bet your bippy" and any other text for the 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your question title says 120 days, so which is it, 20 or 120?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you specify something like this you really should explicitly state what to assign when other ranges result.&lt;/P&gt;
&lt;P&gt;So perhaps another approach:&lt;/P&gt;
&lt;PRE&gt;date want;
   set have;
   if (11 le (dateb -datea) le 20 ) then Newvar=1;
   else if  (dateb -datea) &amp;gt; 20 then NewVar=0;
run;&lt;/PRE&gt;
&lt;P&gt;which leaves Newvar with missing values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 07:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746406#M234142</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-08T07:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746407#M234143</link>
      <description>&lt;P&gt;how about this code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length id dateA dateB 8 YN $1;
  input id dateA:date9. dateB:date9.;
  format dateA dateB date9.;
datalines;
1 10May17 25May17
3 8Nov18 10Dec18
2 13Jun17 26Jun17
;
run;

data want;
  set have;
  if 11=&amp;lt;dateB-dateA=&amp;lt;20 then YN='Y';
  else if 21=&amp;lt;dateB-dateA then YN='N';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jun 2021 07:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746407#M234143</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-06-08T07:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746409#M234145</link>
      <description>&lt;P&gt;What about B dates smaller than or within 10 days from A?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, SAS dates are counts of days, so you can do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 11 le dateb - datea le 20
then y_n = "Yes";
else if dateb - datea gt 20 then y_n = "No";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jun 2021 07:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/746409#M234145</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-08T07:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748017#M234880</link>
      <description>Ballardw,&lt;BR /&gt;Thankyou this achieved exactly what I was after. I used the second approach, so other ranges I was not aware of were made visible by the missing values. My dates were already sas dates, so this made it simple. Sorry about the 120 day typo in the title.&lt;BR /&gt;&lt;BR /&gt;Thank you for your response, much appreciated.&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jun 2021 03:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748017#M234880</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-06-15T03:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748018#M234881</link>
      <description>KurtBremser,&lt;BR /&gt;&lt;BR /&gt;Thankyou for your response. This also achieves what I was after. There were no B dates smaller than or within 10 days from A, thankfully.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jun 2021 03:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748018#M234881</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-06-15T03:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify obs where date B is up tp 120 days greater than date A</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748019#M234882</link>
      <description>Kawakami,&lt;BR /&gt;&lt;BR /&gt;Thank you for you response. Much appreciated.</description>
      <pubDate>Tue, 15 Jun 2021 03:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-obs-where-date-B-is-up-tp-120-days-greater-than/m-p/748019#M234882</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-06-15T03:21:39Z</dc:date>
    </item>
  </channel>
</rss>

