<?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: Difference between dates in SAS doesn't match results in SAS Decision Builder Discussion</title>
    <link>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989563#M28</link>
    <description>&lt;P&gt;Not knowing much about R syntax, what Copilot tells me sounds very convincing.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1781175421157.png" style="width: 758px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/115797iDD10A2E9AA7372DE/image-dimensions/758x694?v=v2" width="758" height="694" role="button" title="Patrick_0-1781175421157.png" alt="Patrick_0-1781175421157.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I'm not going to post more AI answers I can't validate, but I'd suggest you use an AI, provide the SAS code and ask it to replicate this in R.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2026 11:01:46 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2026-06-11T11:01:46Z</dc:date>
    <item>
      <title>Difference between dates in SAS doesn't match results</title>
      <link>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989560#M27</link>
      <description>&lt;P&gt;I need to recreate the code from SAS in R but I am Struggling to get the same results. I can get some rows to be the same but at the same time some other rows are different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help with creating R-code equivalent to the SAS code below?&lt;/P&gt;&lt;PRE&gt;data data_new;  
set data_old;  
months=intck('day30.5',date1,date2);  
run;&lt;/PRE&gt;&lt;P&gt;I've tried this with no luck (month2_sas is the sas result):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;test_data &amp;lt;- data.frame(
  months2_sas = c(5, -2, -8, 10, 4, 7, -8, -7, -2, 2, 7, -7, -8, -11, -9, -8, 0, 11, 0, -2, -1, 7, -4, 7, -6, 10, 6, 9),
  date1 = as.Date(c("2021-06-16","2021-06-16","2020-09-23","2020-09-23","2020-09-23","2022-05-05","2022-03-10","2022-03-10","2022-03-10","2022-03-10","2022-03-10","2022-03-16","2020-02-04","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-10-28","2017-04-28","2017-04-28","2020-10-31","2020-10-31","2023-06-22","2023-06-22")),
  date2 = as.Date(c("2021-12-03","2021-05-05","2020-02-10","2021-08-11","2021-02-09","2022-11-15","2021-08-02","2021-09-07","2022-02-02","2022-06-07","2022-10-31","2021-08-30","2019-06-21","2016-11-08","2017-01-06","2017-02-10","2017-10-02","2018-09-03","2017-10-10","2017-08-08","2017-09-04","2018-04-30","2016-12-09","2017-11-09","2020-05-18","2021-08-13","2023-12-05","2024-03-05"))
)

sas_epoch &amp;lt;- as.Date("1960-01-01")

test_data %&amp;gt;%
  mutate(   
    months_r = floor(as.numeric(date2 - sas_epoch) / 30.5) - 
      floor(as.numeric(date1 - sas_epoch) / 30.5)
  ) %&amp;gt;%
  select(  months2_sas,months_r)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2026 10:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989560#M27</guid>
      <dc:creator>intersoldi</dc:creator>
      <dc:date>2026-06-11T10:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates in SAS doesn't match results</title>
      <link>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989563#M28</link>
      <description>&lt;P&gt;Not knowing much about R syntax, what Copilot tells me sounds very convincing.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1781175421157.png" style="width: 758px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/115797iDD10A2E9AA7372DE/image-dimensions/758x694?v=v2" width="758" height="694" role="button" title="Patrick_0-1781175421157.png" alt="Patrick_0-1781175421157.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I'm not going to post more AI answers I can't validate, but I'd suggest you use an AI, provide the SAS code and ask it to replicate this in R.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2026 11:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989563#M28</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2026-06-11T11:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates in SAS doesn't match results</title>
      <link>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989565#M29</link>
      <description>&lt;P&gt;This is an exact duplicate of a stack overflow question from a month ago which has answers there:&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/79933077/difference-between-dates-in-sas-doesnt-match-results" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/79933077/difference-between-dates-in-sas-doesnt-match-results&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2026 12:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Decision-Builder-Discussion/Difference-between-dates-in-SAS-doesn-t-match-results/m-p/989565#M29</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-06-11T12:00:12Z</dc:date>
    </item>
  </channel>
</rss>

