DATA Step, Macro, Functions and more

extract only character and numeric values, remove special character

Reply
Contributor
Posts: 73

extract only character and numeric values, remove special character

[ Edited ]

hello ALL,

 

I am looking for a  solution which extract only character (A-Z) and numeric (0-9) data, remove special character and space.

Is there any function for same.

 

Output should be : Ram7shaym

 

data temp;
input A $50.;
datalines;
Ram7$%?shay m
;
run;


 

Super Contributor
Posts: 498

Re: extract only character and numeric values, remove special character

Posted in reply to Ritesh_dellvostro
The function translate can do this, maybe you need to call it more than once.
Respected Advisor
Posts: 4,541

Re: extract only character and numeric values, remove special character

Posted in reply to Ritesh_dellvostro

@andreas_lds

Sounds like a use case for the compress() function.

data temp;
  input A $50.;
  wantstr=compress(a,,'kda');
  datalines;
Ram7$%?shay m
;
run;
Super Contributor
Posts: 498

Re: extract only character and numeric values, remove special character

Posted in reply to Ritesh_dellvostro
@Patrick: of course, compress is the easier way to solve this ;-)
Ask a Question
Discussion stats
  • 3 replies
  • 93 views
  • 0 likes
  • 3 in conversation