I have the following piece of code that works fine as a standalone pull:
proc sql; connect to teradata (authdomain='LDAP_auth' SERVER= teramed1 mode = teradata); create table test as select * from connection to teradata (
select sub_ed.eci, sub_ed.hh_episode_bgn,count(sub_ed.incurred_dt) as ed_during_ct
, min(incurred_dt) as ed_during_dt from sudd02a.hh_3_ed sub_ed left join sudd02a.hh_1_episodes sub_ep on sub_ed.eci = sub_ep.eci and sub_ed.hh_episode_bgn = sub_ep.hh_episode_bgn group by 1,2 where sub_ed.incurred_dt between sub_ed.hh_episode_bgn and sub_ep.hh_episode_end); quit;
However, when I wrap the select statement into a left join as part of a much larger pull from Teradata
left join (select sub_ed.eci, sub_ed.hh_episode_bgn
, count(sub_ed.incurred_dt) as ed_during_ct
, min(incurred_dt) as ed_during_dt
from sudd02a.hh_3_ed sub_ed left join sudd02a.hh_1_episodes sub_ep
on sub_ed.eci = sub_ep.eci and sub_ed.hh_episode_bgn = sub_ep.hh_episode_bgn
group by 1,2
where sub_ed.incurred_dt between sub_ed.hh_episode_bgn and sub_ep.hh_episode_end) ed2
on ep.eci=ed2.eci and ep.hh_episode_bgn=ed2.hh_episode_bgn
Enterprise Guide throws the error:
ERROR: Teradata prepare: Datatype Mismatch in THEN/ELSE expression.
I can't figure out what might be causing that error. It's not the ON variables: there's a join just above this one that uses the exact same tables and variables, and it works fine.
It looks like your ed2 variables have a different type.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.