lord12
lord12

Reputation: 2917

Merging data sets in sas

Suppose I have a dataset A:

ID Geogkey
1    A
1    B
1    C
2    W
2    R
2    S

and another dataset B:

ID Temp Date
1   95   1
1  100   2
1  105   3
2   10   1

How do I merge these two datasets so I get three records each for geogkeys with id=1 and one record each for geogkeys where id =2?

Upvotes: 1

Views: 203

Answers (1)

Joe
Joe

Reputation: 63424

Assuming you want the cartesian join, you are best off doing that in SQL, if it's not too big:

proc sql;
create table C as
  select * from A,B
  where A.ID=B.ID
;
quit;

The select * will generate a warning that the ID variables are overwriting; if that's a concern, explicitly spell out your select (select A.ID, A.Geogkey, B.Temp, B.date).

Upvotes: 2

Related Questions