DATA Step, Macro, Functions and more

How to keep only digits when data contents numeric and alphabets?

Reply
Frequent Contributor
Posts: 86

How to keep only digits when data contents numeric and alphabets?

data have;
input a $;
cards;
acc>>>
qe
12.3hjj
78.0
88
run;

Required output;


12.3
78.0
88

I have written in this way:

data have;
input a$;
a1=compress(a,'1234567890.','k');
cards;
acc>>>
qe
12.3hjj
78.0
88
run;

Is there any other way?
PROC Star
Posts: 1,209

Re: How to keep only digits when data contents numeric and alphabets?

[ Edited ]
Posted in reply to rajeshalwayswel

you can do this

 

a1=compress(a,'','kpd');

 

What do you want to do when a does not contain numbers?

Frequent Contributor
Posts: 86

Re: How to keep only digits when data contents numeric and alphabets?

Missing when it contains character, special characters.

Occasional Contributor
Posts: 13

Re: How to keep only digits when data contents numeric and alphabets?

I would be fine with a missing observation

Ask a Question
Discussion stats
  • 3 replies
  • 146 views
  • 3 likes
  • 3 in conversation