Is there any chance to get the CAPTAIN name for the TEAM dataset? Anyone can help, thanks?
DATA TEAM;
INPUT TEAM $ SUBTEAM $ CATEGORY $;
DATALINES;
200 001 .
300 . A1
400 002 .
500 . A2
;
run;
DATA CAPTAIN;
INPUT SUBTEAM $ CATEGORY $ CAPTAIN $;
DATALINES;
001 . GIGGS
. A1 JOHN
002 . MELISSA
. A2 CINDY
;
run;
Desired result:
TEAM SUBTEAM CATEGORY CAPTAIN
200 001 GIGGS
300 A1 JOHN
400 002 MELISSA
500 A2 CINDY
DATA TEAM;
INPUT TEAM $ SUBTEAM $ CATEGORY $;
DATALINES;
200 001 .
300 . A1
400 002 .
500 . A2
;
run;
DATA CAPTAIN;
INPUT SUBTEAM $ CATEGORY $ CAPTAIN $;
DATALINES;
001 . GIGGS
. A1 JOHN
002 . MELISSA
. A2 CINDY
;
run;
proc sort data=team;
by subteam;
run;
proc sort data=captain;
by subteam;
run;
data want;
merge team captain;
by subteam;
run;
proc sort data=want;
by team;
run;
proc print noobs;run;
TEAM | SUBTEAM | CATEGORY | CAPTAIN |
---|---|---|---|
200 | 001 | GIGGS | |
300 | A1 | JOHN | |
400 | 002 | MELISSA | |
500 | A2 | CINDY |
Shouldn't that be
proc sort data=team;
by subteam category;
run;
proc sort data=captain;
by subteam category;
run;
data want;
merge team captain;
by subteam category;
run;
Sir @Tom Spot on. Great catch. Awesome.I was waiting to do a blunder. Hmm we should swap our "age" coz you are young and very wise and I am the one who is old. Just one request -, I would also seek your retirement pension so I can safely retire today. 🙂
Damn the "missing" values made me blind!!!!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: