Hi.
I have two data sets which look like these:
Data set 1:
ID_No Type
A1 1
A1 1
B2 3
C3 4
C3 4
C3 4
D4 4
Data set 2:
ID_No Branch
A1 1
B2 2
C3 3
D4 4
The two data sets have other variables but I don't want them.
But I would like to my data set to look like this:
ID_No Branch Type
A1 1 1
B2 2 3
C3 3 4
D4 4 4
How do I program this?
Thank you very much for your help!
You can do this.
data ds1 (keep=ID_No Type);
input ID_No $ Type;
datalines;
A1 1
A1 1
B2 3
C3 4
C3 4
C3 4
D4 4
;
run;
proc print data=ds1;
run;
data ds2 (keep=ID_No Branch);
input ID_No $ Branch;
datalines;
A1 1
B2 2
C3 3
D4 4
;
run;
proc print data=ds2;
run;
proc sort nodupkey data=ds1;
by ID_No Type;
run;
proc sort data=ds2;
by ID_No;
run;
data outdata;
merge ds1 ds2;
by ID_No;
run;
proc print data=outdata;
run;
Your output will look like this
| ||||||||||||||||||||||||
| ||||||||||||||||||||||||
|
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.