Hello SAS experts,
How to extract numbers before a certain type of strings? I am working on a project to extract the numbers in front of the word UNITS.
My variable, unit, has all types of variations. Here is the example,
Unit |
10 UNITS |
4 UNITS FOR ACCU=259,VERIFY BY ATHENA R |
F.S 199 30 UNITS PER ORDERS |
0 UNITS/FSBS 144 |
0.25ML/125UNITS |
0.35ML/175 UNITS |
1.5 UNITS DOUBLE CHECKED |
10 U8NITS |
10UNITS-BS=306 |
10 U8NITS
10UNITS-BS=306
What I want to get (variable named num_wanted) is
Unit | num_wanted |
10 UNITS | 10 |
4 UNITS FOR ACCU=259,VERIFY BY ATHENA R | 4 |
F.S 199 30 UNITS PER ORDERS | 30 |
0 UNITS/FSBS 144 | 0 |
0.25ML/125UNITS | 125 |
0.35ML/175 UNITS | 175 |
1.5 UNITS DOUBLE CHECKED | 1.5 |
10 U8NITS | 10 |
10UNITS-BS=306 | 10 |
I have tried multiple ways but I couldn't figure how to extract the number before a certain type of string (UNITS have lots of variations such as U, UNIT, UN, UMIT, etc).
Would you help me out? THank you.