问题描述:

I am trying to merge two data sets with a lot of the same observations except one has a column more.

Dataset1 contains data for 20% of the observations and Dataset2 contains observations for the other 80% (+ one column extra). If i run the code below, I get 4037 observations when i merge the two datasets with 315 observation!

proc sql;

create table RateExposure as

select *

from Dataset1, Dataset2

where Dataset1.ID = Dataset2.ID

order by Dataset1.ID;

quit;

If I run

data newDataset;

merge Dataset1 Dataset2;

by ID;

run;

I only get observation for one of the datasets - how can this be?

网友答案:

Try this:

PROC SQL;
CREATE TABLE result AS
SELECT t1.*, t2.extra_column
FROM Dataset1 AS t1
INNER JOIN Dataset2 AS t2 ON (t1.ID = t2.ID)
;
QUIT;
相关阅读:
Top