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;
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;
Alternatively you can use
newx = scan(x,2,' ');
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.