I want to convert a string to number in a SAS SQL PROC.
The oracle-sql functioncs as TO_NUMBER() or INT() do not work.
I also tried the CAST(<my string> AS <target type>) function but it does not recognize the target type INT or INTEGER.
Probably the best way would be to use:
input(your_string_variable, best.) as your_new_numeric_variable
You need to replace your_string_variable and your_new_numeric_variable appropriately. Best. is SAS format ("informat", to be exact) that tries to read in as many reasonable numeric formats as possible, it will work in majority of cases whether representation of a number you have. Still it makes sense to review the results or find a more specific format if you're interested in controlling the input.
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