Help using Base SAS procedures

What is this strange “numeric” to “numeric” explicit conversion?

Accepted Solution Solved
Reply
Super Contributor
Posts: 338
Accepted Solution

What is this strange “numeric” to “numeric” explicit conversion?

Hi Forum,

I was reviewing a code written by another coder where I found a statement highlighted by blue colour which looks strange (at least for me) but SAS does not complains.

data tt;

set t;

……..

…….

Id_No=input(ID,12.);

…………………

……………..

run;

“ID” is a numeric variable.

After I have run the code, the new variable “Id_No” is created which is also a numeric variable.

No complains in the log.

Q:

What I have learned from the SAS class about explicit conversion is this.

Numeric to character conversion =put(Nvar, numeric format)

Character to numeric conversion = input(Cvar, numeric informat)

So, how could numeric to numeric happens like above?

Your help is appreciated.

Miris


Accepted Solutions
Solution
‎01-09-2014 03:55 PM
Trusted Advisor
Posts: 1,189

Re: What is this strange “numeric” to “numeric” explicit conversion?

Hi,

Are you sure there are no complaints in the log?

Below step is like yours.  As you say, the INPUT() function expects a character argument.  SAS converts the numeric ID value to a character value (implicit coversion causing the NOTE: ), and then reads that character value.

29   data a;
30     id=1;
31     id_no=input(id,12.);
32   run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      31:15
NOTE: The data set WORK.A has 1 observations and 2 variables

View solution in original post


All Replies
Solution
‎01-09-2014 03:55 PM
Trusted Advisor
Posts: 1,189

Re: What is this strange “numeric” to “numeric” explicit conversion?

Hi,

Are you sure there are no complaints in the log?

Below step is like yours.  As you say, the INPUT() function expects a character argument.  SAS converts the numeric ID value to a character value (implicit coversion causing the NOTE: ), and then reads that character value.

29   data a;
30     id=1;
31     id_no=input(id,12.);
32   run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      31:15
NOTE: The data set WORK.A has 1 observations and 2 variables
Regular Contributor
Posts: 180

Re: What is this strange “numeric” to “numeric” explicit conversion?

Are you sure ID is a numeric variable?

Acording to the documentation the Input Function expects a character argument. See SAS(R) 9.3 Functions and CALL Routines: Reference

Respected Advisor
Posts: 3,773

Re: What is this strange “numeric” to “numeric” explicit conversion?

When I do it it does complain.  So you are not telling the whole story.

18         data _null_;
19            id = 1;
20            Id_No=input(ID,12.);
21            run;

NOTE:
Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
     
20:16  
Respected Advisor
Posts: 4,606

Re: What is this strange “numeric” to “numeric” explicit conversion?

... Unless you have used OPTIONS NONOTES;

PG

PG
Occasional Contributor
Posts: 9

Re: What is this strange “numeric” to “numeric” explicit conversion?

I never would have found that "little" option on my own - thanks, PG!

Respected Advisor
Posts: 3,773

Re: What is this strange “numeric” to “numeric” explicit conversion?

It's handy when you want to render the LOG useless.  Or if you're programming for job security.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 297 views
  • 4 likes
  • 6 in conversation