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

@Kalai2008 wrote:

Trying to convert the Character variable to Numeric using INPUT function,but getting error  NOTE: Invalid argument to function INPUT

 

OLD_Variable :

10202008AB_RANK00325---(Proc contents : Type: Char . Len:100 Format $100. Informat $100.

 

data test;

set test1;

new_var=input(old_variable, $25.);

run;

 

Output : new_var is still in character format.


 

We're all guessing here...and you still don't have an answer.

 

So....

 

Your old character variable is:  OLD_Variable = '10202008AB_RANK00325---'

 

Post EXACTLY what you want the NEW_Variable to be.  IOW, NEW_Variable = ???

 

Once we have your OLD_Variable ("have") and NEW_Variable ("want"), we can tell you if that is possible.

 

But if you think a numeric variable can contain letters, you need to hit the docs.

 

P.S.:  Some general rules re: put/input/formats/informats:

 

The put function always returns character output, accepts either a numeric or character input, accepts either a numeric or character format, the type of format should match the type of input.

 

The input function always takes a character input, returns either a numeric or character output, accepts either a numeric or character informat, the type of informat should match the type of output.

 

Anything else will result in implicit type conversion or an error.

 

So:

 

new_var=input(old_variable, $25.);

has a character informat, so will return a character result.

 

 

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.

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!

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
  • 15 replies
  • 11728 views
  • 5 likes
  • 11 in conversation