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 🙂

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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