BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rkolupoti9001
Calcite | Level 5

Have_Var

Want_Var
123q987###$###

324s784

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

Hi,

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

Thanks in advance!!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

2 REPLIES 2
Reeza
Super User

Look at the TRANSLATE function Smiley Happy

Or the TRANSWRD

Ksharp
Super User

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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