Hi all,
I'm having some issues with the below code and datasets. I am trying to use a proc sql left join to bring the two datasets together with a new variable, but when I do it adds an extra two from the second dataset instead of only joining to the two already existing in the first dataset. Code and pictures of the three datasets in order below. Thank you in advance for the help!
proc sql; create table eligs as select
a. * ,
b. x_dupIPelig label = "Match with other Elig" as eligIP_flag
from eligIP2 a left join eligIPdups b
on a.screener_ID = b.screener_ID;
quit;
eligIP2:
Eligipdups:
Eligs(Created dataset):
That is the basic behavior of a left join: ALL of the records in the "left" set are joined to ALL of the records that match in the "right" set.
Perhaps you need to join on two or more variables such as
proc sql; create table eligs as select a. * , b. x_dupIPelig label = "Match with other Elig" as eligIP_flag from eligIP2 a left join eligIPdups b on a.screener_ID = b.screener_ID and a.vidnum=b.vidnum ; quit;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.