BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Hdababs
Obsidian | Level 7

Greetings,

How do I calculate age while using a connection to teradata date of birth field.

 

This is what I tried so far, It is embded 

PROC SQL;

CONNECT TO teradata (AUTHDOMAIN=TeradataAuth TDPID=XYZ2 MODE=TERADATA CONNECTION=GLOBAL);

.

..

...

select
DMA.MCID
,frfm.HCC_CD
,DMA.GNDR_NM
,floor ((intck('month',DMA.MBR_BRTH_DT,today()) - (day(today()) < day(DMA.MBR_BRTH_DT))) / 12) as age
,INCRD_YEAR_MNTH_NBR
,case when max(PRORTD_MBR_MNTH_CNT) >0 then 1 else 0 END AS PRORTD_MBR_MNTH_CNT

 

ERROR: Teradata prepare: Syntax error: expected something between '(' and the string 'month'.

1 ACCEPTED SOLUTION

Accepted Solutions
Hdababs
Obsidian | Level 7

Thank you. I initially posted this as a reply to a resolved post. I was able to use teradata syntax:

 

('2022' - extract(year from teradata birth date column name)) as Age

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

You are trying to run SAS functions like INTCK and TODAY on a Teradata database. It won't recognise these. Either use Teradata logic or move your SAS functions to SAS SELECT:

 

PROC SQL;
CONNECT TO teradata (AUTHDOMAIN=TeradataAuth TDPID=XYZ2 MODE=TERADATA CONNECTION=GLOBAL);
create table want as
select  *
,floor ((intck('month',MBR_BRTH_DT,today()) - (day(today()) < day(MBR_BRTH_DT))) / 12) as age
from connection to Teradata
(
select
DMA.MCID
,frfm.HCC_CD
,DMA.GNDR_NM
,DMA.MBR_BRTH_DT
from ......
);
quit;
Hdababs
Obsidian | Level 7

Thank you. I initially posted this as a reply to a resolved post. I was able to use teradata syntax:

 

('2022' - extract(year from teradata birth date column name)) as Age

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 742 views
  • 1 like
  • 3 in conversation