BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Salah
Quartz | Level 8

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
Rick_SAS
SAS Super FREQ

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

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Your question is about how to do this in PROC IML?

 

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

--
Paige Miller
Reeza
Super User

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


 

ballardw
Super User

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.

Salah
Quartz | Level 8

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

 

Rick_SAS
SAS Super FREQ

proc iml;
power = -10:-3;
x= 10**power;
print x[format=E10.];
Ksharp
Super User
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;
Rick_SAS
SAS Super FREQ

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.

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!
Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 7 replies
  • 995 views
  • 0 likes
  • 6 in conversation