BookmarkSubscribeRSS Feed
mariko5797
Pyrite | Level 9

Suppose my datasets are organized like so:

mariko5797_0-1627065540572.png

I want to combine the information from dataset 1 and dataset 2 such that my columns are DISEASE, BMIGRP, COUNT_A, and COUNT_B.

I don't want to lose any information. That is, I want to maintain all the DISEASES granted they exist in at least one of the datasets like so:

mariko5797_1-1627065764454.png

 

Is there an efficient way to achieve this? Thank you in advance.

 

 

1 REPLY 1
Tom
Super User Tom
Super User

Just the MERGE statement.

Just make sure the data sets are sorted first. They do not appear sorted in your photographs.

data want;
  merge dataset1 dateset2;
  by disease bmigrp;
run;