BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

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

3 REPLIES 3
novinosrin
Tourmaline | Level 20
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
Tom
Super User Tom
Super User

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;
novinosrin
Tourmaline | Level 20

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

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 653 views
  • 0 likes
  • 3 in conversation