DATA Step, Macro, Functions and more

Input

Reply
Occasional Contributor LHV
Occasional Contributor
Posts: 15

Input

Hi,

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........

data new;

set _prodsavail;

dd=input(licensed,12.);    /*licensed is a Numeric variable*/

run;

Thanks,

Super User
Posts: 5,437

Input

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.

Data never sleeps
Occasional Contributor LHV
Occasional Contributor
Posts: 15

Input

Hi,

Thanks for info.

If i use below statement, it is giving the 'dd' as character, in that case what is the difference between INPUT and PUT?

dd=input(licensed,$12.); 

Thnaks,

PROC Star
Posts: 7,489

Input

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.

New Contributor
Posts: 2

Input

Hi,

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.

Super User
Super User
Posts: 7,074

Input

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.

Ask a Question
Discussion stats
  • 5 replies
  • 276 views
  • 0 likes
  • 5 in conversation