05-03-2018 04:35 PM
05-03-2018 04:39 PM
You are using the wrong informat:
You should be using:
If you use 8.2, it is telling SAS to look for a decimal point. If it doesn't find one, assume the last two digits belong after the decimal point.
05-03-2018 04:44 PM
Z is already a variable. So I'm not sure what question you are asking. At any rate .....
The meaning of 8.2 doesn't change. It still means to read 8 characters, and see if they contain a decimal point. If there is a decimal point, use it. But if there is no decimal point, assume the last two digits should fall after the decimal point.
If your original variable is numeric, rather than character, you are asking for trouble using the INPUT function. The INPUT function expects to read a character string.
05-03-2018 05:00 PM
I have a variable z=10, but in a character format.
To multiply it by 2, i convert the z to a numeric during my multiplication:
However, my result is .2, not 20. Why is this the case? It is onlu 20 when I use input(z, 8.)
You might try a simple
x = 2*z;
and examine the result and the log.
SAS will attempt to convert character values to numeric to do computations like this in a data step. The conversion is usually pretty good. Though if you want to do calculations the question is always why was the variable created as character in the first place.