name=j** ney
in the above data value there is a two * are there after J.Using compress we can remove this *.But i need to remove only 1 *.How can i write the code.
How about use "prxchange".
name="j** ney";
txt = prxchange('s/\*\*/*/',-1,name);
put txt=;
Best Regards,
I agree with Hoz, prxchange is the way to do this. A slight modification to Hoz's code will replace any number of consecutive * to a single *.
txt = prxchange('s/\*+/*/',-1,name);
Using a regular expression with prxchange() is for sure a very powerful way of modifying a string.
Considering that it's such a simple text pattern and the question is asked in the "Getting started" forum using a function like TRANSTRN() is also acceptable.
data _null_;
myVariable='name=j** ney';
myVariable=TRANSTRN(myVariable,'**','*');
put myVariable=;
run;
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.