Hello
I am trying to learn the topic of convert char to numeric.
I know the formula: Numeric=INPUT(char, informat);
My problem is that sometimes it is difficult for me to recognize the in informat.
For example:
convert char value 123,456.78 to numeric.
I saw that the solution is Numeric=INPUT(char, COMMA12.);
Numeric value returned 123456.78
My question is why the informat is COMMA12.?
I see that there are 2 numbers after the point and 6 numbers before the point.
I was sure that the informat should be comma6.2 because there are 6 numbers in left of point and 2 in right of point
For example:
There are 2 records under char variable : 82.04 and 108498.19
I would like to convert these values into numeric
I saw that there are multiple solutions.
Numeric=INPUT(char, COMMA10.2);
Numeric=INPUT(char, COMMA32.);
Numeric=INPUT(char, COMMA15.);
My question is why there are multiple informats that can be used in this case???
Is there not only one correct informat?
I also want to understand please what is the correct informat in this example
Thanks in advance
Joe
d
specifies the powerof 10 by which to divide the value. If the data contain decimal points,the d value is ignored. This argument is optional.
@Ronein wrote:
I don't understand. Can you try to explain it again please?
char value 123,456.78 has decimal point.
what should be the informat?
Is it possible that there are multiple informats that can be used in this example?
Only include a number of decimal places on the INFORMAT if you want SAS to imply where the decimal point should be when the string being read does NOT contain one. So with 32.2 as the INFORMAT the string '1234567' will become the number 12,345.67. But if the string has a decimal point the number of decimal places listed in the informat is ignored. So a string like '1234.567' becomes the number 1,234.567
Thank you.
In char value 108498.19 there are 2 number after decimal point.
What is the correct informat here?
Is it important to see how many number in right side of decimal point?
Can you explain please. I still not understand
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.