- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would like to extract just the number 27.59 from the following Positive (27.59). Irrespective of the text before the parenthesis.
thank you
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SCAN() will work well as long as the text before (or after if searching backwards) does not include parentheses.
number = input(scan(string,1,'()'),32.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SCAN() will work well as long as the text before (or after if searching backwards) does not include parentheses.
number = input(scan(string,1,'()'),32.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It sounds like you know the number that you are searching for in advance; is that correct? If so, see the code below. I'm using a combination of the FIND, LENGTH, and SUBSTR functions. I'm sure there are other ways to do it as well.
Regards,
Jim
Results:
Code:
DATA _NULL_;
Search_For = '27.59';
Search_Len = LENGTHN(Search_For);
Var = 'Positive (27.59)';
Number = SUBSTR(Var, FIND(Var,'27.59'), Search_Len);
PUTLOG "NOTE: " Number=;
PUTLOG "NOTE- " ;
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Tom and Jim for the quick response.
I used the following..ct_value= scan(Result,2,'()');
I just need the number with in parenthesis for all the records.