Proc sort data=d1;
by name;
run;
Proc sort data=d2;
by name;
run;
data want;
merge d1 d2;
by name;
run;
If you have other variables of the same name in both sets you need to let us know as the behavior with merge is the properties of the common variable will come from the first data set on the merge statement but the values from the second.
If common named variables are different in type you will get an error and the merge will fail.
Proc sort data=d1;
by name;
run;
Proc sort data=d2;
by name;
run;
data want;
merge d1 d2;
by name;
run;
If you have other variables of the same name in both sets you need to let us know as the behavior with merge is the properties of the common variable will come from the first data set on the merge statement but the values from the second.
If common named variables are different in type you will get an error and the merge will fail.
Hi Smitha9, as long as both data sets have a common variable name with the same characteristics and are sorted before hand, merging can be done in one of two ways.
The first is using a Data step:
DATA WORK.Merge; MERGE WORK.D1 WORK.D2; BY name; RUN;
You could also use the PROC SQL statement.
SAS Innovate 2025: Register Now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9. Sign up by Dec. 31 to get the 2024 rate of just $495. Register now!