<?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: Proc sql joint with interval between 2 dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899194#M355416</link>
    <description>&lt;P&gt;Then you have to use INTNX or INTCK with a DTDAY interval.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 05:44:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-10-19T05:44:51Z</dc:date>
    <item>
      <title>Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899152#M355395</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;My Date_1 &amp;lt; Date_2 so I would like to get only the observation with 7 days diffrence. Could you tell me if my code is right :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table Result as select a.*, b.* from total_RE as a
		left join SUP as b on a.pers=b.pers
			and intck('day',b.D_1, a.D_2)&amp;lt;7;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 16:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899152#M355395</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-10-18T16:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899154#M355396</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Date_1 &amp;lt; Date_2 so I would like to get only the observation with 7 days diffrence. Could you tell me if my code is right :&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you actually try running this code? SAS will tell you if the code is right, and do so more quickly and more authoritatively than anyone here can do (especially since we don't have your data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There do not appear to me to be any syntax errors (but again SAS will give you are more authoritative answer). I question the logic in the code which doesn't seem to match the words you used; 7 days difference would be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intck('day',b.D_1, a.D_2)=7&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 16:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899154#M355396</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-18T16:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899158#M355398</link>
      <description>&lt;P&gt;Since dates in SAS are counts of&amp;nbsp;&lt;EM&gt;days&lt;/EM&gt;, the INTCK call is not necessary.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and a.D_2 - b.D_1 = 7&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 17:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899158#M355398</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-18T17:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899186#M355409</link>
      <description>&lt;P&gt;Exactly 7 days?&amp;nbsp; 7 days or less?&amp;nbsp; Or less than 7 days?&lt;/P&gt;
&lt;P&gt;Assuming your date variables have DATE values then they are already stored as a number of days, so there is no need to use any special functions to check the differences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To test if D2 is between D1 and up to 7 days after D1 just use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Result as 
  select a.*, b.* 
  from total_RE as a
  left join SUP as b
    on a.pers=b.pers
   and a.D_2 between b.D_1 and b.D_1+7
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you actually have DATETIME values then you would need to use INTNX() or INTCK() since those values are stored as number of seconds.&amp;nbsp; But you would need to use the DTDATE interval and not the DATE interval.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 03:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899186#M355409</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-19T03:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899192#M355415</link>
      <description>Thank you very much!&lt;BR /&gt; I have datetime  values and I would like to chose 7 days or less interval. How to indicate the datetime interval please?</description>
      <pubDate>Thu, 19 Oct 2023 05:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899192#M355415</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-10-19T05:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joint with interval between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899194#M355416</link>
      <description>&lt;P&gt;Then you have to use INTNX or INTCK with a DTDAY interval.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 05:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joint-with-interval-between-2-dates/m-p/899194#M355416</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-19T05:44:51Z</dc:date>
    </item>
  </channel>
</rss>

