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!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 775 views
  • 0 likes
  • 2 in conversation