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

Hello everyone. I am trying to remove one string (the letters TRD_ ) from a secondary string. The issue I have is that tranwrd always leaves a space in the resulting word, which I cannot have (I also can't string spaces because the words have other spaces I Need).

For example, I would like the following to happen.

CL_TRD_Borrower Name  =CL_Borrower Name.

TRD_Answer one  =Answer One.

What I am getting is

CL_TRD_Borrower Name  =CL_ Borrower Name.

TRD_Answer one  = Answer One.

Is there an option I am not aware of to do this?

Thanks!

Brandon

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

TRANSTRN

data _null_;
  
x = 'CL_TRD_Borrower Name';
   z = transtrN(x,
'TRD_',trimn(' '));
   put (_all_)(=);
   run;

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

TRANSTRN

data _null_;
  
x = 'CL_TRD_Borrower Name';
   z = transtrN(x,
'TRD_',trimn(' '));
   put (_all_)(=);
   run;
Anotherdream
Quartz | Level 8

Thank you kindly. I knew this was possible!

data_null__
Jade | Level 19

You could also use TRANWRD to change to something unique and then compress the unique character.  TRANSTRN is better.

Anotherdream
Quartz | Level 8

yeah that's actually what I was doing. I was using tranwrd to put it to the hyphenated a in unicode, and then compressing that value, but I figured there HAD to be an easier way to do it so I figured I'd ask the experts.

Glad I did. Thanks again!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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