08-08-2013 01:42 PM
Is it possible to get the lenght of a number in proc sql. Even better if the number of decmail places is included.
I tried converting the number to a character and then getting the length. But this automatically rounded the numbers removing the decimal places. Which is not what I want
08-08-2013 02:14 PM
So, you would want length=infinity for irrational numbers such as Pi and e, as well as for rational numbers with infinite decimal expansions such as 1/3?
08-08-2013 03:06 PM
You could try something like this . . .adapt to make it work with your data . . . .
/* generate some random numbers for illustration */
data have ;
do i = 1 to 100;
id + 1;
x = round(ranuni(i)*10000,.01);
/* convert number to character and determine length */
/* note: result will be dependent on number of decimals and includes decimal point */
select t.*, strip(put(t.x, 12.2)) as xchar format=$15., length (strip(put(t.x, 12.2))) as lenxchar
from have t;