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
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: 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
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: 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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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