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
| ||||||||||||||||||||||||
| ||||||||||||||||||||||||
|
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.