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

Ready to join fellow brilliant minds for the SAS Hackathon?

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

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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