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;
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 -
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;
Fully agree to @Oligolas: using tranwrd four-times is imho the easiest way to solve the problem.
so as i understand best way is using 4 times tranwrd function as i did 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.