My raw data is in the form
Var
12 A+
14 A+
AB+ 19
AB:20
20
25
27 New
I want to extract the numeric portion of it only.
Can anybody please help me how to process this data in sas.
Thank you in advance. Rgds.
You could use the COMPRESS function, which takes the form
COMPRESS(<source><, chars><, modifiers>)
Update: There are many ways to achieve this. As per their comments, RWill and Keith provide the best solutions:
var2=input(compress(var,compress(var,,"d")),best.);
or even better:
var2=input(compress(var,,"kd"),best.);
Just as @itzy mentioned above, Perl regular expression will do with ease:
var2=prxchange("s/[^0-9]//",-1,var);
This will remove all non-numerical characters. In this statement, 's/' begins a string, [^0-9] means all non-numerical characters. -1 defines an until-end match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With