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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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