I need to extract only digits from a variable.Say for instance I have a field "drug name" with values Symbort 25 mg, Avalide 125 ml,Xyntha 1050.
I need only 25,125 1050.
Thanks for your time and help,
You can use the compress function to strip all of the characters. All the letters of the alphabet are listed in both upper and lower case within quotes. The result will be a character variable containing only the digits. You can then use an input function to convert the character to a numeric.
I'm sure that there is a more elegant solution but this one works.
compress(drug_name,,a) gives the same results. See the documentation for COMPRESS.0
What about fields with two numbers int hem? Say "Vytorin 10/80'? The code above gives '10/80' as the result but that may not be what you want. COMPRESS has lots of options to give you more control on the parsing.