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

Hi i want to get only numeric values where this is the input

 

data have;
length var1 $30.;
var1='hdhdxha82873jdjsd';output;
var1= 9293293991 ;output;
var1='123431hud';output;
var1=1223444;output;
run;

 

and the required output is

 

var1

9293293991

1223444

 

How can I extract just the numeric values. thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  if lengthn(compress(var1,"","d"))=0 then output;
run;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  if lengthn(compress(var1,"","d"))=0 then output;
run;
Aayushi_17
Quartz | Level 8

but what if that var1 has decimal value like this var1= 929329.3991 ;output; will it be able to get the output

RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  if lengthn(compress(var1,".","d"))=0 then output;
run;
Aayushi_17
Quartz | Level 8
Thanks for your quick response.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 704 views
  • 3 likes
  • 2 in conversation