BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

@animesh123 sure. Please mark my answer as the accepted solution if the code works for you.

 

The Compress Function keeps only digits from the string. 'kd' = 'keep digits'. 

 

The Input Function converts the character string to numeric.

View solution in original post

10 REPLIES 10
PeterClemmensen
Tourmaline | Level 20

What numeric value do you want to extract?

PeterClemmensen
Tourmaline | Level 20

Try this

 

data test;
   string    = 'a1b2c3df456';
   newstring = input(compress(string, , 'kd'), 8.);
run;
animesh123
Obsidian | Level 7
Thanks @PeterClemmensen

I will try to run this ,is it possible if you could explain me this ?
PeterClemmensen
Tourmaline | Level 20

@animesh123 sure. Please mark my answer as the accepted solution if the code works for you.

 

The Compress Function keeps only digits from the string. 'kd' = 'keep digits'. 

 

The Input Function converts the character string to numeric.

animesh123
Obsidian | Level 7

Hey @PeterClemmensen 

 

Is it anyway possible we could do the same using _num_?

PeterClemmensen
Tourmaline | Level 20

What does _num_ mean here?

animesh123
Obsidian | Level 7
_NUMERIC_ specifies all numeric variables that are already defined in the current DATA step.
PeterClemmensen
Tourmaline | Level 20

So you want to expand this logic to all numeric variables in your data step?

animesh123
Obsidian | Level 7
Yes, is it possible to pull out the numeric variables using _NUMERIC_ to get same output as we did by compress function?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 1893 views
  • 2 likes
  • 2 in conversation