Hello,
How do you appropriately select Employee_Gender (a column that does NOT exist in Donor_list table)? This syntax gives me an ERROR: Unresolved reference to table/correlation name b. However, if I include the Employee_payroll table on original FROM statement I get ERROR: Ambiguous reference, column Employee_ID is in more that one table. What am I missing?
proc sql;
select a.Employee_ID, a.Employee_Name, b.Employee_Gender
from Mydata.Donor_list as a
where Employee_ID in
(select b.Employee_ID
from SQL.Employee_payroll as b
where a.Employee_ID = b.Employee_ID)
quit;
Thanks,
David
In this case, how about using an inner join instead of a sub-query:
proc sql;
select a.Employee_ID, a.Employee_Name, b.Employee_Gender
from Mydata.Donor_list as a, SQL.Employee_payroll as b
where a.Employee_ID = b.Employee_ID
quit;
In this case, how about using an inner join instead of a sub-query:
proc sql;
select a.Employee_ID, a.Employee_Name, b.Employee_Gender
from Mydata.Donor_list as a, SQL.Employee_payroll as b
where a.Employee_ID = b.Employee_ID
quit;
Hi Hai,
Don't know why a join didn't cross my mind. That worked. Thank you,
David
You'll have to add a semi-colon, just before the quit statement, in order for Haikuo's code to run.
And, dependent upon one's preferences, the following code does the same thing:
proc sql;
select a.Employee_ID, a.Employee_Name, b.Employee_Gender
from Mydata.Donor_list as a
inner join SQL.Employee_payroll as b
on a.Employee_ID = b.Employee_ID
;
quit;
Thanks, Art. Obviously my compiler wasn't working :smileysilly:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.