Have_Var | Want_Var |
---|---|
123q987 | ###$### |
324s784 | ###$### |
386 | ### |
58881 | ##### |
afgelk | $$$$$$ |
Hi,
I want to translate 0-9 character # and A-Z to $
Thanks in advance!!!!
data have;
input x $20.;
cards;
123q987
;
run;
data want;
set have;
t=prxchange('s/\d/#/',-1,x);
y=prxchange('s/[a-z]/$/i',-1,t);
drop t;
run;
Look at the TRANSLATE function
Or the TRANSWRD
data have;
input x $20.;
cards;
123q987
;
run;
data want;
set have;
t=prxchange('s/\d/#/',-1,x);
y=prxchange('s/[a-z]/$/i',-1,t);
drop t;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.