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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1591 views
  • 0 likes
  • 2 in conversation