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.

Share:
11,112
paolof89
Author by

paolof89

I'm a computer engineer that doesn't like to program.

Updated on June 04, 2022

Comments

  • paolof89
    paolof89 almost 2 years

    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.

  • paolof89
    paolof89 over 5 years
    Can you specify how to use the parameter best.?