Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid numeric data...while it supposed to stay character...

Status
Not open for further replies.

irinnew

Technical User
Mar 19, 2005
81
US
Hi Everybody,

One more question from my side! (it is not my week:-(

After I run code below I got a strange log message. Actually my input data are all character data and I double checked them with PROC CONTENTS.

It looks like as the result of my code system treats field Fno as numeric and complains that it is invalid.

I have 2 questions:
1. Why it started to be treated as numeric now?
2. How to avoid the problem?

________________________________________________________
data INPUTXREF;
466 merge INPUTDATA(IN=A)
467 REF (IN=B);
468
469 A=substr(Fno,1,9);
470 b=substr(MC_sub_num,1,9);
471 if A;
472
473 run;

NOTE: Character values have been converted to numeric values at the places given by:
(Line):(Column).
469:7 470:7
NOTE: Invalid numeric data, 'N17777777' , at line 469 column 7.

 
A and B are numeric flags set by the IN option on the merge statement. What you are doing is trying to reset the value of A with a char variable. What I would suggest is use another variable name for your substr() function.
ex.
fno_sub = substr(fno,1,9);
mc = substr(mc_sub_num,1,9);

Klaz
 
Yep, spot on. You misunderstood the error message.
Code:
NOTE: Character values have been converted to numeric values at the places given by:
It's not complaining that the field is numeric, it's saying that it has converted a Character variable to a numeric variable. Basically it's tried to convert the substring of FNO (character) into a numeric variable (A), which as Klaz points out is a numeric variable which you have already defined in the IN= options. The variables A and B defined in the IN= options are set to 1 or 0 (generally referred to a True or False), but you aren't using these in your merge step, I would carefully look at this to make sure that's giving you what you want. Also, there's no By statement in your merge. I understand though that you may have cut these out of your code to make it shorter in your post though.
Ain't SAS fun? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top