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

Dear All,

 

I have a few values in a variable A of a dataset as follows:

 

     A

Superb xyz

XYZ super

good xyz

good XyZ girl

 

I would like to find the term xyz whether upcase or lowcase or propcase and replace with some term (example: pqr) in the whole dataset. How can i do that ??

 

In simple words i would like to replace xyz with pqr.

 

Any help ?

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input A $ 1 - 20;
datalines;
Superb xyz    
XYZ super     
good xyz      
good XyZ girl 
;

data want;
   set have;
   A = tranwrd(upcase(A), 'XYZ', 'pqr');
run;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input A $ 1 - 20;
datalines;
Superb xyz    
XYZ super     
good xyz      
good XyZ girl 
;

data want;
   set have;
   A = tranwrd(upcase(A), 'XYZ', 'pqr');
run;

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
  • 1 reply
  • 731 views
  • 0 likes
  • 2 in conversation