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: Save the Date
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!