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
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
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
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
When I do it it does complain. So you are not telling the whole story.
... Unless you have used OPTIONS NONOTES;
PG
I never would have found that "little" option on my own - thanks, PG!
It's handy when you want to render the LOG useless. Or if you're programming for job security.
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!
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.