BookmarkSubscribeRSS Feed
LHV
Calcite | Level 5 LHV
Calcite | Level 5

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,

5 REPLIES 5
LinusH
Tourmaline | Level 20

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
LHV
Calcite | Level 5 LHV
Calcite | Level 5

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,

art297
Opal | Level 21

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.

pcorbridge
Calcite | Level 5

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.

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 916 views
  • 0 likes
  • 5 in conversation