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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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