I'm currently working on a project that involves utilizing PROC SQL for data manipulation, and I've encountered a challenge with a particular JOIN operation. Specifically, I am trying to join two tables using PROC SQL, and despite double-checking my syntax, I seem to be getting unexpected results.
Here's a simplified version of the query:
PROC SQL;
CREATE TABLE CombinedTable AS
SELECT A.*, B.*
FROM TableA A
LEFT JOIN TableB B
ON A.ID = B.ID;
QUIT;
Despite seemingly correct syntax, I'm not getting the expected results. Has anyone else experienced a similar issue with PROC SQL joins, or is there something I might be overlooking? Any insights, suggestions, or examples would be greatly appreciated.
Show us examples for the datasets in text form (ideally as DATA steps with DATALINES, so we can immediately recreate your datasets with a simple copy/paste and submit) which illustrate your issue, and the expected result from those particular datasets.
First hint: do not use the asterisk like this when doing a join, use explicit variable lists for at least one dataset.
The variable ID (and maybe others as well) will cause WARNINGs in the log.
What specifically is your unexpected result, vs the expected result?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.