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 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!

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
  • 12756 views
  • 5 likes
  • 11 in conversation