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;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1071 views
  • 0 likes
  • 2 in conversation