General Format Syntax

FedSQL formats have the following syntax:
[ $ ] format [w ] . [d]
Arguments

$

indicates a character format; its absence indicates a numeric informat.

format

names the format. The format is a SAS format, a FedSQL format, or a user-defined format that was previously defined with the INVALUE statement in PROC FORMAT. For more information about user-defined formats, see PROC FORMAT in Base SAS Procedures Guide.

w

specifies the format width, which for most formats is the number of columns in the input data.

d

specifies a decimal scaling factor in the numeric formats. FedSQL divides the input data by 10 to the power of d.

Tip When the value of d is greater than 15, the precision of the decimal value after the fifteenth decimal place might not be accurate.
Formats always contain a period (.) as a part of the name. If you omit the w and the d values from the format, SAS uses default values. The d value that you specify with a format tells FedSQL to display that many decimal places, regardless of how many decimal places are in the data. Formats never change or truncate the internally stored data values.
For example, in DOLLAR10.2, the w value of 10 specifies a maximum of 10 columns for the value. The d value of 2 specifies that two of these columns are for the decimal part of the value, which leaves eight columns for all the remaining characters in the value. This includes the decimal point, the remaining numeric value, a minus sign if the value is negative, the dollar sign, and commas, if any.
If the format width is too narrow to represent a value, FedSQL tries to squeeze the value into the space available. Character formats truncate values on the right. Numeric formats sometimes revert to the BESTw. format. The BESTw. format is the default format for writing numeric values. BESTw. rounds the value, and if SAS can display at least one significant digit in the decimal portion within the width specified, BESTw. produces the result in decimal. Otherwise, it produces the result in scientific notation. SAS always stores the complete value regardless of the format that you use to represent it. At least 3 columns must be available for the BESTw. format to be applied. FedSQL prints blanks if you do not specify an adequate width. To illustrate, the following request:
select put(12345, 3.);
returns the output 1E4. Meanwhile, this request:
select put(12345, 2.);
returns a blank value.
If you use an incompatible format, such as using a numeric format to write character values, FedSQL first attempts to use an analogous format of the other type. If this is not feasible, an error message that describes the problem appears in the SAS log.
Last updated: February 23, 2017