BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I have a data set that all values in column x start with "Team" value.

Task: Delete from all rows in column X the value "Team"

Existing values:

Team 2-5
Team 7-8
Team 9-11

 

New values should be:

2-5
7-8
 9-11

 

How can I do it please?

 

 

data aaa;
INFILE DATALINES DELIMITER=',' DSD;
input x1 $;
cards;
Team 2-5
Team 7-8
Team 9-11
;
run;

 

 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

One way

 

data have;
input x $20.;
datalines;
Team 2-5
Team 7-8
Team 9-11
;

data want;
    set have;
    newx=tranwrd(x, 'Team ', '');
run;
Shmuel
Garnet | Level 18

Alternatively you can use 

newx = scan(x,2,' ');

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 389 views
  • 0 likes
  • 3 in conversation