Desktop productivity for business analysts and programmers

Need to translate 0-9 to # and A-Z to $

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Need to translate 0-9 to # and A-Z to $

Have_Var

Want_Var
123q987###$###

324s784

###$###
386###
58881#####
afgelk$$$$$$

Hi,

I want to translate 0-9 character # and A-Z to $

Thanks in advance!!!!


Accepted Solutions
Solution
‎07-02-2015 10:12 AM
Grand Advisor
Posts: 9,576

Re: Need to translate 0-9 to # and A-Z to $

Code: Program

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;

View solution in original post


All Replies
Grand Advisor
Posts: 17,338

Re: Need to translate 0-9 to # and A-Z to $

Look at the TRANSLATE function Smiley Happy

Or the TRANSWRD

Solution
‎07-02-2015 10:12 AM
Grand Advisor
Posts: 9,576

Re: Need to translate 0-9 to # and A-Z to $

Code: Program

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;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 363 views
  • 5 likes
  • 3 in conversation