Hi all,
I want to merge two data sets in SAS. I want to show by using example:
Group Value
A 10
A 8
A 6
B 7
B 9
B 11
it is my first data set. I have the second dataset as well:
Group Volume
A 2
B 3
I want to merge these two data sets. The result should be:
Group Value Volume
A 10 2
A 8 2
A 6 2
B 7 3
B 9 3
B 11 3
I hope, i can explain it. Many thanks.
if by datastep
data first;
input Group $ Value @@;
datalines;
A 10 A 8 A 6 B 7 B 9 B 11
;
run;
data second;
input Group $ Volume @@;
datalines;
A 2 B 3
;
run;
proc sort data=first; by Group; run;
proc sort data=second; by Group; run;
data want; merge first second; by Group; run;
proc print data=want noobs; run;
if by datastep
data first;
input Group $ Value @@;
datalines;
A 10 A 8 A 6 B 7 B 9 B 11
;
run;
data second;
input Group $ Volume @@;
datalines;
A 2 B 3
;
run;
proc sort data=first; by Group; run;
proc sort data=second; by Group; run;
data want; merge first second; by Group; run;
proc print data=want noobs; run;
Thank you very much. it works
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.