09-24-2014 08:46 AM
I am facing some trouble when I want to convert a character variable to a numeric one.
At start, my variable "A" is character such like :
14 866 M€
I used the compress function to have my have my variable appearing as following :
and so on...
Then I tried to convert it, I tried both input function and the "not rigourous" technique of multiply it by 1.
Each time I got the same error message saying :
Invalid numeric data, A='119.' , at line 16 column 6.
and my new variable B (supposedly numeric) has only missing values...
Could you help me try to figure this out please ?
Thanks a lot
09-24-2014 10:08 AM
Thank you mohamed
Here is my code (with the *1 technique) :
data test ; set figures ;
CA = A*1;
In fact, in the log, it seems sas sees the data as e.g. "119." because it reads it like that (in the log) : 119€
But the € doesn't appear in my table ! I even ran a compress function before to suppress the € !
I have a way to do what I want (I substr a string as (length(myvariable)-1) and then *1) but it is not very good.
So if you have a solution to handle that invisible € sign, it would be great !
09-24-2014 10:52 AM
It look like your data set examples have problem,
14 866 M€
does it contain spaces and the currency spaced from the value.
Does your data look like this? Or please give well typed sample of your dataset?
09-24-2014 10:03 AM
Input val $10.;
REMOVE_CHAR = COMPRESS(VAL,'MA');
NUMONLY = INPUT(REMOVE_CHAR,5.);
I have used same COMPRESS and INPUT functions, but I didn't get any error