<?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 INTCK Function Not Working For Me in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476076#M30900</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with email campaign data and I am trying to narrow down all activities that occurred only within 14 days AFTER the email send date. TO QC my data, I noticed the numbers being to high for a specific campaign, so I've narrowed down to look just at that specific campaign which was sent on 02/01/18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I originally have the INTCK function in the "ON" section for the join, but I moved it to "WHERE"&amp;nbsp; since this sped up the processing time. However, the numbers remain the same and as you can see, I'm still getting date values in the activity_date field that are more than 14 days after the send date (2/1). You can see the output in the attached pic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code for reference. Can someone tell me if the see an error in how I am using INTCK?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table tableau.test as
select a.person_id,
a.execution_id, 
a.campaign_id, 
datepart(a.campaign_send_datetime) as send_date format= mmddyy8.,
datepart(b.activity_date) as activity_date format= mmddyy8.,
	   max(case when activity_type_dim_id = 5 then 1 else 0 end) as opened,
	   max(case when activity_type_dim_id = 2 then 1 else 0 end) as clicked,
	   max(case when activity_type_dim_id in (10,11,14) then 1 else 0 end) as bounced
	from ldmprod.vw_email_campaign_history as a
	left join ldmprod.vw_email_campaign_activity as b
	on a.execution_id = b.execution_id and
	   a.person_id = b.person_id
	where datepart(a.campaign_send_datetime) &amp;gt;= '01JAN2018'd 
	&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;and intck('day', b.activity_date, a.campaign_send_datetime) &amp;lt;= 14&lt;/STRONG&gt;&lt;/FONT&gt;
	and upcase(a.receipient_id) not like '%SEED%'
	and upcase(a.receipient_id) not like '%SD%'
	and a.campaign_id like 'M00884004904%'
	and (substr (a.campaign_id_id, 1, 3) = 'M00' 
	or substr (a.campaign_id, 1, 3) = 'O00')
	group by 1,2,3,4
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jul 2018 17:14:21 GMT</pubDate>
    <dc:creator>Dogo23</dc:creator>
    <dc:date>2018-07-06T17:14:21Z</dc:date>
    <item>
      <title>INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476076#M30900</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with email campaign data and I am trying to narrow down all activities that occurred only within 14 days AFTER the email send date. TO QC my data, I noticed the numbers being to high for a specific campaign, so I've narrowed down to look just at that specific campaign which was sent on 02/01/18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I originally have the INTCK function in the "ON" section for the join, but I moved it to "WHERE"&amp;nbsp; since this sped up the processing time. However, the numbers remain the same and as you can see, I'm still getting date values in the activity_date field that are more than 14 days after the send date (2/1). You can see the output in the attached pic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code for reference. Can someone tell me if the see an error in how I am using INTCK?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table tableau.test as
select a.person_id,
a.execution_id, 
a.campaign_id, 
datepart(a.campaign_send_datetime) as send_date format= mmddyy8.,
datepart(b.activity_date) as activity_date format= mmddyy8.,
	   max(case when activity_type_dim_id = 5 then 1 else 0 end) as opened,
	   max(case when activity_type_dim_id = 2 then 1 else 0 end) as clicked,
	   max(case when activity_type_dim_id in (10,11,14) then 1 else 0 end) as bounced
	from ldmprod.vw_email_campaign_history as a
	left join ldmprod.vw_email_campaign_activity as b
	on a.execution_id = b.execution_id and
	   a.person_id = b.person_id
	where datepart(a.campaign_send_datetime) &amp;gt;= '01JAN2018'd 
	&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;and intck('day', b.activity_date, a.campaign_send_datetime) &amp;lt;= 14&lt;/STRONG&gt;&lt;/FONT&gt;
	and upcase(a.receipient_id) not like '%SEED%'
	and upcase(a.receipient_id) not like '%SD%'
	and a.campaign_id like 'M00884004904%'
	and (substr (a.campaign_id_id, 1, 3) = 'M00' 
	or substr (a.campaign_id, 1, 3) = 'O00')
	group by 1,2,3,4
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476076#M30900</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T17:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476079#M30901</link>
      <description>&lt;P&gt;Do the variables contain date values or datetime values?&amp;nbsp; You are treating them differently in different places.&lt;/P&gt;
&lt;P&gt;Here you are treating the value as if it contains datetime values (# of seconds).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datepart(b.activity_date) as activity_date format= mmddyy8.,
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But here you are treating them as if they have date values (# of days).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	and intck('day', b.activity_date, a.campaign_send_datetime) &amp;lt;= 14&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could tell INTCK that you are using datetime values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	and intck('dtday', b.activity_date, a.campaign_send_datetime) &amp;lt;= 14&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or convert them yourself like you did before.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	and intck('day', datepart(b.activity_date), datepart(a.campaign_send_datetime)) &amp;lt;= 14&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476079#M30901</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-06T17:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476084#M30902</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for catching that. The data did indeed have a datetime value for both tables (e.g. 10NOV2015:15:48:05.000000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using both of you recomendations, but I still got activity date values well past 2/15 (see attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and intck('day', datepart(b.activity_date), datepart(a.campaign_send_datetime)) &amp;lt;= 1&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21610iAEA866F4AF6C75D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476084#M30902</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T17:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476086#M30903</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21611iAFC7AB0C346624C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476086#M30903</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T17:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476089#M30904</link>
      <description>&lt;P&gt;Since you are only printing two digit years are you sure they are in the same century?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 17:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476089#M30904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-06T17:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476096#M30905</link>
      <description>&lt;P&gt;Simplify.&amp;nbsp; Since SAS dates are stored as integers, just subtract the two dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(DATEPART(a.campaign_send_datetime) - DATEPART(b.activity_date)) &amp;lt;= 14&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 18:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476096#M30905</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2018-07-06T18:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476097#M30906</link>
      <description>&lt;P&gt;Not a SQL expert, but isn't the fact that you're not grouping by activity_date, but you're not applying a grouping function to it, an issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 18:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476097#M30906</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-06T18:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476135#M30910</link>
      <description>&lt;P&gt;Going through the data set, i'm only seeing everything in 2018. Elsewhere in the code I've also say "where &amp;gt;= January 1st, 2018".&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 20:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476135#M30910</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T20:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476136#M30911</link>
      <description>&lt;P&gt;I tried this too but it seems I'm still getting activity dates after 2/15.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 20:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476136#M30911</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476139#M30912</link>
      <description>&lt;P&gt;Good catch Tom, that may have been left over from a field I've removed since then. I changed it to group by the first 3 fields. However, it didn't change the outcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 20:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476139#M30912</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-06T20:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476171#M30920</link>
      <description>&lt;P&gt;I think you need to include both activity_date and send_date - the date version not the datetime -&amp;nbsp; in your GROUP BY, to avoid your data being re-merged. Check your SAS log and if you are getting a note about data being re-merged then this needs to be fixed as it could well be interfering with your data selection.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 23:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476171#M30920</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-07-06T23:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK Function Not Working For Me</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476565#M30943</link>
      <description>&lt;P&gt;So I think I figured this out. The datetime fields needed to be be switched in the INTCK function. I noticed when I added on INTCK fuction in the select area to visually see the date interval, all of them were 0 or negative numbers which is why ways "where less than 14" did not work. However, I'm sure I still would've needed you help about the&amp;nbsp;datetime vs. date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 18:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/INTCK-Function-Not-Working-For-Me/m-p/476565#M30943</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-07-09T18:58:21Z</dc:date>
    </item>
  </channel>
</rss>

