/***************************************************************************************************************** SAS file name: Convert_Character_to_Numeric.sas File location: _________________________________________________________________________________________________________________ Purpose: To demonstrate the correct way of converting variables from character to numeric in SAS using the INPUT Function. Author: Peter Clemmensen Creation Date: 02/09/2017 This program supports the blog post "Convert from Numeric to Character in SAS - The Easy and the Right Way" on SASnrd.com *****************************************************************************************************************/ /* From Character to Numeric */ /* Naive Approch */ data _null_; CharNum = "1.000,00"; /* Character value of 1000 */ Number = CharNum*1; /* Naive conversion method */ put Number=; /* Print to log */ run; data _null_; CharNum = "1,000,000"; /* EU character value of 1mio */ Number = CharNum*1; /* Naive conversion method */ put Number=; /* Print to log */ run; /* Correct Approach */ data ConvertData; CharNum1 = "1.000,00"; /* Character value of 1000 */ CharNum2 = "1,000,000"; /* EU character value of 1mio */ Number1 = input(CharNum1, commax10.2); /* Correct conversion method */ Number2 = input(CharNum2, comma10.); /* Correct conversion method */ put Number1= Number2=; /* Print to log */ run; proc print data=ConvertData; run;