BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mirisage
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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
The Boston Area SAS Users Group is hosting free webinars!
Next up: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.

View solution in original post

6 REPLIES 6
Quentin
Super User

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
The Boston Area SAS Users Group is hosting free webinars!
Next up: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.
CTorres
Quartz | Level 8

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

data_null__
Jade | Level 19

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):(Column).
     
20:16  
PGStats
Opal | Level 21

... Unless you have used OPTIONS NONOTES;

PG

PG
cwcaulkins
Fluorite | Level 6

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

data_null__
Jade | Level 19

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1430 views
  • 4 likes
  • 6 in conversation