/* Concatenate (or Union) the two data sets*/
data GroupA;
input ID$ Product$;
datalines;
A Apple
B Grapes
B Orange
C Banana
E Apple
run;
data GroupB;
input ID$ Product$ Size$;
datalines;
B Shirt S
C Pants M
D Jacket L
E Tie M
E Wallet L
run;
data concat;
set GroupA GroupB;
run;
proc sort data=concat;
by ID;
run;
/* Merge the two data sets*/
data merged;
merge GroupA GroupB;
by ID;
run;
SET appends data, ie stacks the datasets on top of each other.
MERGE adds data in a side to side fashion, making you data wider.
You SHOULD NOT be expecting the same results from the different code.
All the different options and methods are explained here:
https://documentation.sas.com/?docsetId=lrcon&docsetTarget=n1tgk0uanvisvon1r26lc036k0w7.htm&docsetVe...
@mahossain wrote:
/* Concatenate (or Union) the two data sets*/
data GroupA;
input ID$ Product$;
datalines;
A Apple
B Grapes
B Orange
C Banana
E Apple
run;data GroupB;
input ID$ Product$ Size$;
datalines;
B Shirt S
C Pants M
D Jacket L
E Tie M
E Wallet L
run;data concat;
set GroupA GroupB;
run;
proc sort data=concat;
by ID;
run;
/* Merge the two data sets*/
data merged;
merge GroupA GroupB;
by ID;
run;
SET appends data, ie stacks the datasets on top of each other.
MERGE adds data in a side to side fashion, making you data wider.
You SHOULD NOT be expecting the same results from the different code.
All the different options and methods are explained here:
https://documentation.sas.com/?docsetId=lrcon&docsetTarget=n1tgk0uanvisvon1r26lc036k0w7.htm&docsetVe...
@mahossain wrote:
/* Concatenate (or Union) the two data sets*/
data GroupA;
input ID$ Product$;
datalines;
A Apple
B Grapes
B Orange
C Banana
E Apple
run;data GroupB;
input ID$ Product$ Size$;
datalines;
B Shirt S
C Pants M
D Jacket L
E Tie M
E Wallet L
run;data concat;
set GroupA GroupB;
run;
proc sort data=concat;
by ID;
run;
/* Merge the two data sets*/
data merged;
merge GroupA GroupB;
by ID;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.