<?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: To find the difference of two dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800486#M314920</link>
    <description>&lt;P&gt;I suggest you research them yourself first, then if there's something you don't understand or are having trouble applying, ask in here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChanceTGardener_0-1646588411980.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69188iA16EF04194987AF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChanceTGardener_0-1646588411980.png" alt="ChanceTGardener_0-1646588411980.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Mar 2022 17:44:59 GMT</pubDate>
    <dc:creator>ChanceTGardener</dc:creator>
    <dc:date>2022-03-06T17:44:59Z</dc:date>
    <item>
      <title>To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799603#M314443</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to find out the difference between two variables: a dateofservice and two years back from that date of service. In fact, I want to use it in a where clause and say where lookbackperiod is less than or equal to two years. Years can be expressed in term of days as well.&lt;/P&gt;
&lt;P&gt;How can I do this in proc sql/ data steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;blue &amp;amp; blue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799603#M314443</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-02T16:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799604#M314444</link>
      <description>&lt;P&gt;Look into the YRDIF() function and then incorporate it into your where clause.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/vdmmlcdc/1.0/lefunctionsref/p1pmmr2dtec32an1vbsqmm3abil5.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/vdmmlcdc/1.0/lefunctionsref/p1pmmr2dtec32an1vbsqmm3abil5.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799604#M314444</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2022-03-02T16:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799605#M314445</link>
      <description>This is a great resource by Rick Wicklin on doing what you need: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html&lt;/A&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799605#M314445</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-03-02T16:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799606#M314446</link>
      <description>&lt;P&gt;More details may help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The general function to modify a date value a given amount is INTNX but that requires a base date to calculate from&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
    datevalue = '15Mar2022'd;
    newdate1 = intnx('year',datevalue, -2,'E');
    newdate2 = intnx('year',datevalue, -2,'S');
    newdate3 = intnx('year',datevalue, -2,'B');
   format datevalue new: date9.;
run;
&lt;/PRE&gt;
&lt;P&gt;The first parameter is an interval, typical are year, month, week, day though others a acceptable, then the date value to calculate from, then the number of intervals, optional parameters return the End, Beginning or Same date of the interval.&lt;/P&gt;
&lt;P&gt;This function can be used with WHERE as long as the date value is available, either a literal date or variable.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799606#M314446</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-02T16:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799990#M314623</link>
      <description>&lt;P&gt;Hello teammate,&lt;/P&gt;
&lt;P&gt;My datevalue is a variable, which its content are different dates as 11/12/2019 or 0/05/2020, etc, I need to pull dates that are 2 years far from 12,31,2021.&lt;/P&gt;
&lt;P&gt;Please give me a chance to read the read the link and come back here.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Blue&amp;amp;Blue&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 22:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799990#M314623</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-03T22:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799992#M314624</link>
      <description>&lt;P&gt;I still don't understand what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide example data, AND the desired result.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 22:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/799992#M314624</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-03T22:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800257#M314760</link>
      <description>&lt;P&gt;What is 'far'? Is it two years ahead or two years behind? Here's an example you can work with and tell us what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date :mmddyy10.;
format date mmddyy10.;
datalines;
1 11/12/2019
2 05/05/2020
3 12/31/2019
4 12/31/2018
5 12/31/2020
6 03/04/2022
7 04/05/1980
8 12/31/2022
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I ended up using the YRDIF function to compute the actual days between the two.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
		years_from = yrdif("31DEC2021"d, date, 'actual');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use FLOOR or CEIL functions to get what you want since we don't know.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
		years_from = yrdif("31DEC2021"d, date, 'actual');
		years_ceil = ceil(years_from);
		years_floor = floor(years_from);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="maguiremq_0-1646416593980.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69163iEFFE3FDCA4275457/image-size/medium?v=v2&amp;amp;px=400" role="button" title="maguiremq_0-1646416593980.png" alt="maguiremq_0-1646416593980.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's really important that we know what you want. Please always provide example data like I have above. Also provide a data set showing exactly what you want. It allows people to answer the questions and increases the likelihood of people answering your questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 17:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800257#M314760</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-03-04T17:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800476#M314911</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;thanks for this. This helped me in doing my project.&amp;nbsp;&lt;BR /&gt;blue&amp;amp;blue&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2022 16:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800476#M314911</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-06T16:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800477#M314912</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bringing Example made it more clear. Thanks for it.&lt;/P&gt;
&lt;P&gt;blue&amp;amp;blue&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2022 16:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800477#M314912</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-06T16:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800479#M314914</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please explain about ceiling and floor?&lt;/P&gt;
&lt;P&gt;thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;blue&amp;amp;blue&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2022 16:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800479#M314914</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-06T16:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: To find the difference of two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800486#M314920</link>
      <description>&lt;P&gt;I suggest you research them yourself first, then if there's something you don't understand or are having trouble applying, ask in here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChanceTGardener_0-1646588411980.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69188iA16EF04194987AF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChanceTGardener_0-1646588411980.png" alt="ChanceTGardener_0-1646588411980.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2022 17:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-the-difference-of-two-dates/m-p/800486#M314920</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2022-03-06T17:44:59Z</dc:date>
    </item>
  </channel>
</rss>

