DATA Step, Macro, Functions and more

capture value within the parentheses using function

Accepted Solution Solved
Reply
Regular Contributor
Posts: 181
Accepted Solution

capture value within the parentheses using function

Hi!  

 

I have values that look like this:

 

VAR_NAME

(3) left hearing 12JAN2017

(14) right hearing 30JAN2017

 

The only thing i need to capture from this value are the numbers within the parentheses.  Can someone help me use a scan or substr to capture this (or other function) ?

 

 

Thanks!

 

 

 

 

 

 


Accepted Solutions
Solution
‎12-05-2017 07:04 PM
Super User
Posts: 23,244

Re: capture value within the parentheses using function

Posted in reply to novinosrin

new_var=scan(var_name, 1, '()');

View solution in original post


All Replies
PROC Star
Posts: 1,561

Re: capture value within the parentheses using function

if the pattern is exactly the same as your sample-

new_var=compress(scan(var_name, 1), '()');

 

Solution
‎12-05-2017 07:04 PM
Super User
Posts: 23,244

Re: capture value within the parentheses using function

Posted in reply to novinosrin

new_var=scan(var_name, 1, '()');

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 118 views
  • 0 likes
  • 3 in conversation