## negative exponents

Hello

I am not sure how to ask this question.

Is there a way to format the output in case of very very small numbers without rounding them

For example 0.0000006  can I have SAS to write the output as 6 e^-6 or anything similar?

I know that there is round(x,0.0001) but I want to keep the number as it is just the output to be in short hand.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: negative exponents

``````
proc iml;
power = -10:-3;
x= 10**power;
print x[format=E10.];
``````
7 REPLIES 7

## Re: negative exponents

Where do you want to see this formatted output? Please be very detailed.

--
Paige Miller

## Re: negative exponents

Formats.

Exponential formats are probably what you want...but where are you planning to use this in IML?

Not 100% sure this can be used in whatever step you're looking for it.

@Salah wrote:

Hello

I am not sure how to ask this question.

Is there a way to format the output in case of very very small numbers without rounding them

For example 0.0000006  can I have SAS to write the output as 6 e^-6 or anything similar?

I know that there is round(x,0.0001) but I want to keep the number as it is just the output to be in short hand.

Thank you

## Re: negative exponents

The format is amazingly enough the Ew. format, for exponential. For example e10. preserves 10 significant digits

```data example;
x= 0.0000002345;
put x= e10.;
run;```

with a result of

```x=2.345E-07
```

The format can be used to display 32 characters but the documentation displays up to 14 significant digits.

## Re: negative exponents

Thank you for the help. But I am not sure this works in SAS/IML!

## Re: negative exponents

``````
proc iml;
power = -10:-3;
x= 10**power;
print x[format=E10.];
``````  Ksharp
Super User

## Re: negative exponents

Rick,
Shouldn't be
x= 10##power;
??
** in IML is matrix multiply operator ?

proc iml;
a={1 2,
4 2};
x= a##2;
y= a**2;
print x / y;
quit;

## Re: negative exponents

When the base is a scalar, the ** and ## operators are equivalent. I used 10**power since most DATA step programmers are more familiar with the ** operator for raising a scalar to a power.

But, sure, you can use ## if you prefer.

From The DO Loop