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. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 910 views
  • 0 likes
  • 4 in conversation