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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 15350 views
  • 5 likes
  • 11 in conversation