Help using Base SAS procedures

PROC SQL CREATE TABLE

Reply
N/A
Posts: 0

PROC SQL CREATE TABLE

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;
Respected Advisor
Posts: 4,173

Re: PROC SQL CREATE TABLE

Posted in reply to deleted_user
.....
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
N/A
Posts: 0

Re: PROC SQL CREATE TABLE

Thanks! That does help!
Ask a Question
Discussion stats
  • 2 replies
  • 129 views
  • 0 likes
  • 2 in conversation