BESTw. Format

SAS chooses the best notation.
Category: Numeric
Alignment: right
See: BESTw. Format: z/OS in SAS Companion for z/OS

Syntax

BESTw.

Syntax Description

w
specifies the width of the output field.
Default:12
Range:1–32
Tip:If you print numbers between 0 and .01 exclusively, then use a field width of at least 7 to avoid excessive rounding. If you print numbers between 0 and -.01 exclusively, then use a field width of at least 8.

Details

When a format is not specified for writing a numeric value, SAS uses the BESTw. format as the default format. The BESTw. format writes numbers as follows:
  • Values are written with the maximum precision, as determined by the width.
  • Integers are written without decimals.
  • Numbers with decimals are written with as many digits to the left and right of the decimal point as needed or as allowed by the width.
  • Values that can be written within the given width are written without trailing zeros.
  • Values that cannot be written within the given width are written with the maximum allowable number of decimal places as determined by the width.
  • Extreme values might be written in scientific notation.
SAS stores the complete value regardless of the format that is used.

Comparisons

  • The BESTw. format writes as many significant digits as possible in the output field, but if the numbers vary in magnitude, the decimal points do not line up. Integers print without a decimal.
  • The Dw.p format writes numbers with the desired precision and more alignment than the BESTw format.
  • The BESTDw.p format is a combination of the BESTw. format and the Dw.p format in that it formats all numeric data, and it does a better job of aligning decimals than the BESTw. format.
  • The w.d format aligns decimal points, if possible, but does not necessarily show the same precision for all numbers.

Example

The following statements produce these results.
SAS Statements
Result
----+----1
x=1257000;
put x best6.;
 
1.26E6
x=1257000;
put x best3.;
 
1E6

See Also

Formats: