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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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