BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Solly7
Pyrite | Level 9

Hi, i need to remove unwanted characters from my 'description column'..please note that the length of the string is not the same on all the rows below. But i only need those last six digits which starts with 1 on an each every row.

 

Data Have                                                      Data Want

 

Description                                                     Description

magma ret3x122354565  190121                  190121                   

buddyoli1234533 180203                               180203

brasty omo1903737383 190506                     190506

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Then simply do

 

data have;
input description :$&200.;
datalines;
magma ret3x122354565 190121
buddyoli1234533 180203     
brasty omo1903737383 190506
;

data want;
    set have;
    newdecription=scan(description, -1);
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Is it always the last part of the string?

Solly7
Pyrite | Level 9

That is Correct!

PeterClemmensen
Tourmaline | Level 20

Then simply do

 

data have;
input description :$&200.;
datalines;
magma ret3x122354565 190121
buddyoli1234533 180203     
brasty omo1903737383 190506
;

data want;
    set have;
    newdecription=scan(description, -1);
run;
Solly7
Pyrite | Level 9
Bro, it works perfectly fine.. thank you
PeterClemmensen
Tourmaline | Level 20

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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