SAS PROC SQL - How to convert string to number
11,112
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.
Comments
-
paolof89 almost 2 years
I want to convert a string to number in a SAS SQL PROC. The oracle-sql functioncs as
TO_NUMBER()
orINT()
do not work. I also tried theCAST(<my string> AS <target type>)
function but it does not recognize the target type INT or INTEGER. -
paolof89 over 5 yearsCan you specify how to use the parameter best.?