<?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 Stuck on SQL intck query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732675#M228324</link>
    <description>&lt;P&gt;I want to calculate the age of a customer but sas is giving me errors. Anyone know how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%let todaysDate = %sysfunc(today()) format date09.;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.QUERY_FOR_TABLE AS&lt;BR /&gt;SELECT&lt;BR /&gt;t1.SubscriberKey,&lt;BR /&gt;Datepart(t1.CustDOB) format date09. AS DOB,&lt;BR /&gt;&amp;amp;todaysDate AS TodaysDate,&lt;BR /&gt;intck('year', DOB, TodaysDate) as Age&lt;BR /&gt;FROM&lt;BR /&gt;CASE.CUSTOMERS t1&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError sapUiTreeNodeSelected"&gt;ERROR: Function INTCK requires a numeric expression as argument 2.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Function INTCK requires a numeric expression as argument 3.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The following columns were not found in the contributing tables: DOB, TodaysDate.&lt;/DIV&gt;</description>
    <pubDate>Sat, 10 Apr 2021 07:06:37 GMT</pubDate>
    <dc:creator>ckyborg4</dc:creator>
    <dc:date>2021-04-10T07:06:37Z</dc:date>
    <item>
      <title>Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732675#M228324</link>
      <description>&lt;P&gt;I want to calculate the age of a customer but sas is giving me errors. Anyone know how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%let todaysDate = %sysfunc(today()) format date09.;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.QUERY_FOR_TABLE AS&lt;BR /&gt;SELECT&lt;BR /&gt;t1.SubscriberKey,&lt;BR /&gt;Datepart(t1.CustDOB) format date09. AS DOB,&lt;BR /&gt;&amp;amp;todaysDate AS TodaysDate,&lt;BR /&gt;intck('year', DOB, TodaysDate) as Age&lt;BR /&gt;FROM&lt;BR /&gt;CASE.CUSTOMERS t1&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError sapUiTreeNodeSelected"&gt;ERROR: Function INTCK requires a numeric expression as argument 2.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Function INTCK requires a numeric expression as argument 3.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The following columns were not found in the contributing tables: DOB, TodaysDate.&lt;/DIV&gt;</description>
      <pubDate>Sat, 10 Apr 2021 07:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732675#M228324</guid>
      <dc:creator>ckyborg4</dc:creator>
      <dc:date>2021-04-10T07:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732676#M228325</link>
      <description>&lt;P&gt;If you do&lt;/P&gt;
&lt;P&gt;%put &amp;amp;todaysdate. ;&lt;/P&gt;
&lt;P&gt;you can see that the value of &amp;amp;todaysdate is&lt;/P&gt;
&lt;PRE&gt;    %put todaysdate is: &amp;amp;todaysdate.;
todaysdate is: 22379 format date09.
&lt;/PRE&gt;
&lt;P&gt;Which in not way resembles and number. And if you actually have the value formatted it is still not a number.&lt;/P&gt;
&lt;P&gt;You want for this example:&lt;/P&gt;
&lt;PRE&gt;%let todaysDate = %sysfunc(today());

PROC SQL;
CREATE TABLE WORK.QUERY_FOR_TABLE AS
SELECT
t1.SubscriberKey,
Datepart(t1.CustDOB) format date09. AS DOB,
&amp;amp;todaysDate AS TodaysDate,
intck('year', DOB, TodaysDate) as Age
FROM
HACKCASE.CUSTOMERSCOTIAREWARDS t1
;
QUIT;
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 05:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732676#M228325</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-10T05:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732678#M228326</link>
      <description>I believe you need "calculated dob" and "calculated todaysdate".</description>
      <pubDate>Sat, 10 Apr 2021 05:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732678#M228326</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-10T05:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732686#M228332</link>
      <description>&lt;P&gt;I tried copy pasting the same code in, but it still gives me the same errors. I ran the code without the intck line and checked the column value type, they both indicated they were of type numeric.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 07:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732686#M228332</guid>
      <dc:creator>ckyborg4</dc:creator>
      <dc:date>2021-04-10T07:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732698#M228336</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this working code should get you where you want to be.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
 set sashelp.class;
 dob=INTNX('DAY',today(),-age*365);
 format dob ddmmyy10.;
run;

%let todaysDate = %sysfunc(today());

PROC SQL;
CREATE TABLE WORK.QUERY_FOR_TABLE AS
SELECT
t1.Name,
t1.dob format=date09. AS DOB,
&amp;amp;todaysDate. AS TodaysDate format=ddmmyy10.,
intck('year', DOB, &amp;amp;todaysDate.) as Age
FROM
work.abc t1
;
QUIT;
/* end of program */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 11:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732698#M228336</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-10T11:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on SQL intck query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732810#M228352</link>
      <description>&lt;P&gt;intck() returns the number of interval boundaries. If the interval is year then the number of boundaries between 31Dec2020 and 01Jan2021 would be 1.&lt;/P&gt;
&lt;P&gt;If you are really after the age then using the yrdif() function with basis 'age' is likely more what you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let todaysDate = %sysfunc(today());

PROC SQL;
  CREATE TABLE WORK.QUERY_FOR_TABLE AS
    SELECT 
      t1.SubscriberKey,
      Datepart(t1.CustDOB) format date09. AS DOB format=date9.,
      &amp;amp;todaysDate AS TodaysDate format=date9.,
      floor(yrdif(Datepart(t1.CustDOB), &amp;amp;todaysDate,'age')) as Age
    FROM
      CASE.CUSTOMERS t1
  ;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;yrdif() returns the age with a decimal component. Use floor() - or int() - to only get the integer part of the age.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 01:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stuck-on-SQL-intck-query/m-p/732810#M228352</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-11T01:42:18Z</dc:date>
    </item>
  </channel>
</rss>

