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

After importing an Excel file with a numeric variable, Var1, I'm getting the following error:

 

    "NOTE: Numeric values have been converted to character values at the places given by..."

 

I've tried the following statements, but still get the same error. What might be causing this & what's the fix?  There are no character values in the data.

 

   new9=input(Var1,4.1);
   drop Var1;
   rename new9=Var1;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Why is it that you think VAR1 was character after the import?  Did you run a PROC CONTENTS?

 

Your code might be correct for a character VAR1.  (It also might not ... the 4.1 informat will insert a decimal point if it doesn't find one in the incoming string, but that's a secondary issue.)

 

The fact that you are getting the conversion message when you execute your sample statements means that VAR1 is already numeric.  The software had to convert it to character in order to apply the INPUT function.  Run a PROC CONTENTS before fiddling with the data to find out which variable is the real troublemaker.

View solution in original post

5 REPLIES 5
art297
Opal | Level 21

According to the documentation: Use INPUT to convert character values to numeric values or other character values.

 

If it's already numeric, you should just rename it (if desired) and apply whatever format you want for the variable.

 

Art, CEO, AnalystFinder.com

 

JRake
Calcite | Level 5
Is my code snippet incorrect?
art297
Opal | Level 21

Sounds like you only want/need something like:

 

data want;
  set have (rename=(var1=var9));
  format var9 4.1;
run;

Astounding
PROC Star

Why is it that you think VAR1 was character after the import?  Did you run a PROC CONTENTS?

 

Your code might be correct for a character VAR1.  (It also might not ... the 4.1 informat will insert a decimal point if it doesn't find one in the incoming string, but that's a secondary issue.)

 

The fact that you are getting the conversion message when you execute your sample statements means that VAR1 is already numeric.  The software had to convert it to character in order to apply the INPUT function.  Run a PROC CONTENTS before fiddling with the data to find out which variable is the real troublemaker.

Reeza
Super User

Proc import wouldn't generate that error, so what's the code that generates the error. 

 

Was the import correct, is the value read in correctly? Proc import guesses when importing since Excel doesn't follow any database standards so the data can be anything. 

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
  • 5 replies
  • 829 views
  • 0 likes
  • 4 in conversation