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!!!!
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.