BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi, I am trying to join two tables. Table A has fewer observations than Table B.
I only want the additional information from table B added to Table A.
I am getting, according to the log, 1 fewer observation in the new table named
CHARTER than in the original table I wanted to add an additional field to from Table B. Why?

PROC SQL;
CREATE TABLE CHARTER AS
SELECT
A.COCODE,
A.COUNTY,
A.DISTRICT,
A.ENROLLMENT,
A.SCHOOL,
A.SCHOOL_CODE,
A.TYPE,
B.CHARTER,
B.DIST_CODE,
B.PHYS_CITY
FROM CHECK A INNER JOIN KINDER B
ON (A.SCHOOL_CODE=B.SCH_CODE);
QUIT;
2 REPLIES 2
Patrick
Opal | Level 21
.....
from check a LEFT JOIN kinder B
.....

A INNER JOIN gives you only the rows with common keys in both tables.
If table A has a row where the key doesn't match with table B then this row won't be part of the result table.

Use a left join and you won't loose rows from table A (but of course: one row in the result table will have missings for all vars coming from table B).

HTH
Patrick
deleted_user
Not applicable
Thanks! That does help!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1098 views
  • 0 likes
  • 2 in conversation