BESTw. Format

SAS chooses the best notation.

Category: Numeric
Alignment: Right
Interaction: When the DECIMALCONV= system option is set to STDIEEE, the output that is written using this format might differ slightly from previous releases. For more information, see DECIMALCONV= System Option in SAS System Options: Reference.

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, use a field width of at least 7 to avoid excessive rounding. If you print numbers between 0 and -.01 exclusively, 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 attempts to write numbers that balance the conflicting requirements of readability, precision, and brevity. Here are several rules:
  • Values are written with the maximum readable precision, as determined by the width. The maximum precision for floating-point numbers might be limited to 14 or 15 digits, 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.
  • Extreme values and values with leading or trailing zeros might be written in scientific notation to fit into the specified width, to increase the precision, or to simplify the magnitude of the number. Extremely small values might be written as 0 if the width is too small for scientific notation.
  • Trailing zeros are not written.
  • If a value cannot be represented in either decimal or scientific notation in the width that is specified, the output field is filled with asterisks.
  • The behavior of the BESTw. format is affected by the setting of the DECIMALCONV option. For more information, see DECIMALCONV= System Option in SAS System Options: Reference. These rules are generally applicable regardless of the option setting.

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 are printed 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 Statement
Result
----+----1
x=1257000;
put x best6.;
 
1.26E6
x=1257000;
put x best3.;
 
1E6

See Also

Formats: