BookmarkSubscribeRSS Feed
gillshreyas
Calcite | Level 5

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.

2 REPLIES 2
Kurt_Bremser
Super User

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.

 

LinusH
Tourmaline | Level 20

What specifically is your unexpected result, vs the expected result?

Data never sleeps

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 480 views
  • 0 likes
  • 3 in conversation