Online File

How to use this page


Rick Aster: Professional SAS Programming Shortcuts: Contents

Chapter 11
Program
Writing scientific notation


data _null_;
   do value = 123456789, -.0000123456789, .123456789;
      if value then exponent = floorz(log10(abs(value)));
      else exponent = 0;
      mantissa = value/10**exponent;
      if 0 <= exponent <= 99 then do;
         if mantissa >= 0 then put mantissa f7.5 'e' exponent z2.;
         else put mantissa f7.4 'e' exponent z2.;
         end;
      else if exponent >= -99 then do;
         if mantissa >= 0 then put mantissa f6.4 'e' exponent z3.;
         else put mantissa f6.3 'e' exponent z3.;
         end;
      else do;
         if mantissa >= 0 then put mantissa f5.3 'e' exponent z4.;
         else put mantissa f5.2 'e' exponent z4.;
         end;
      end;
run;

 O /\

Global
Statements

RICK ASTER

SAS

BOOKS

Tech | Dictionary

Download | Rastinate

Rick Aster

Professional SAS Programming Shortcuts

Contents/Online Files

Corrections

Catalog Page