BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to replace  following substrings within Model varaible.

Change   "niz_crd_max"   to   "max"
Change    "Second_Max_niz_crd"   to   "SecondMax"
Change    "50000"   To   "50K"
Change    "20000"   TO  "20K"

 

data aaa;
Model='niz_crd_max-1.1-50000-50';output;
Model='Second_Max_niz_crd-1';output;
Model='niz_crd_max-1.2'output;
Model='Second_Max_niz_crd-1-50000-50';output;
Run;
4 REPLIES 4
Oligolas
Barite | Level 11

Use the tranwrd function for example or explain your problem?

Here is a useful PDF for character functions, you'll find anything you need and even more.

________________________

- Cheers -

Ronein
Onyx | Level 15
data aaa;
Model='niz_crd_max-1.1-50000-50';output;
Model='Second_Max_niz_crd-1';output;
Model='niz_crd_max-1.2';output;
Run;
data bbb;
set aaa;
ModelNew1 = tranwrd(Model,'niz_crd_max', 'Max');
ModelNew2 = tranwrd(ModelNew1,'Second_Max_niz_crd', 'SecondMax');
ModelNew3 = tranwrd(ModelNew2,'50000', '50K');
ModelNew4 = tranwrd(ModelNew3,'20000', '20K');
run;
andreas_lds
Jade | Level 19

Fully agree to @Oligolas: using tranwrd four-times is imho the easiest way to solve the problem.

Ronein
Onyx | Level 15

so as i understand best way is using 4 times tranwrd function as i did 🙂

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

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
  • 4 replies
  • 2298 views
  • 3 likes
  • 3 in conversation