02-17-2012 08:09 AM
Could anyone explain about why Input function displays the message in the log: NOTE: Numeric values have been converted to character values at the places given by:
but in the actual dataset it is not converting the value. As per the functionality of Input function, it should convert character to Numeric. It is quite confusing........
dd=input(licensed,12.); /*licensed is a Numeric variable*/
02-17-2012 08:13 AM
The message implies that the input function needs to convert the input parameter to Char, before it applies the numerical format - and the end result of the input function numerical.
02-17-2012 08:58 AM
Yes, it is confusing and I think it is an artifact of SAS's attempt to be a system that will let you work with character and numeric variables without having to distinguish between them.
It was a valiant effort, but one that really couldn't hold up given the complexity of the various functions, procs, formats and informats that have evolved over the years.
I think the safest rule of thumb is to use the input function ONLY when converting from characters to numeric, and ONLY use put when converting from numeric to character.
That way you won't get the annoying messages in your log and you won't run into brick walls when the character/numeric distinction can't be avoided.
02-17-2012 08:54 AM
INPUT will convert a character variable to numeric variable.
As you are trying to convert the 'license' variable that is already numeric, SAS will convert it to character first prior to the conversion back to numeric.
The PUT function will return a numeric variable as a character string.
02-17-2012 09:35 AM
What are you actually trying to do?
If you just want to assign the value of licensed to dd then you do not need a function.
If you want to convert the numeric variable licensed to a character value then use the PUT function instead of the INPUT function.
PUT always generates character result.
INPUT results depends on the type of the informat used. That is why $12. generates character variables and 12. generates a numeric variable.
There are also PUTN, PUTC, INPUTN and INPUTC which have been added over the years. They have the advantage of allowing the format/informat to come from a variable.