Hello,
I have asked to check if data present in any of the four tables then populate the condition as Y else N based on the key columns.
How can I achieve it.
Regards,
Nithya
Hi and welcome to the SAS community 🙂
When you ask a question like this, you have to be more specific. For example: "if data present". What data? And what four tables?
Please be more specific in your requirements. And if you want a full usable code answer, provide example data.
Regards.
Please post test data in the form of a datastep:
and what you want to see out at the end. Showing some code and saying it doesn't work tells us nothing. We need to be able to see inputs/outputs to have any idea of what is going on.
On your code, I strongly doubt that is the best solution. You are first off selecting all columns from all four tables, e.g. a.*. That cannot be what you want is it? Second you are using left joins, so only data which appears in the preceeding data will appear in the output. So only data in B which has a match in a on the clause will appear, again I highly doubt this is what you mean.
What I would suggest is that you create datasets of the data you actually want, then do a simple merge:
proc sql; connect to teradata as db(...); create table a as (select fcl_id,cust_id,app_id,"A" as tab1 from cond1 order by fcl_id,cust_id,app_id); create table b as (select fcl_id,cust_id,app_id,"B" as tab2 from cond2 order by fcl_id,cust_id,app_id); create table c as (select fcl_id,cust_id,app_id,"C" as tab3 from cond3 order by fcl_id,cust_id,app_id); create table d as (select fcl_id,cust_id,app_id,"D" as tab4 from cond4 order by fcl_id,cust_id,app_id); disconnect from db; quit; data want; merge a b c d; by fcl_id cust_id app_id; run;
You will then have a complete list of the merged id variables, and four columns tab1-4 which show presence in each table.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.