SAS implements
a set of formats that can be used to transform basic character and
numeric values into formatted character values. In ADO, formats are
controlled with the "SAS Formats" customized Recordset property.
This property takes a string value that specifies the format that
you want to use, and specifies any optional overriding information.
The string value also lists one or more columns to which the format
should be applied. Use the following form to enter the string value:
[+]COLUMN[=FORMAT[w].[d]]
Here
is an explanation of the form:
-
+, an optional modifier that exposes the column in two conditions:
formatted and unformatted.
-
COLUMN, the name of a column in the recordset (which is the same as the
variable name in the SAS data set). If you need to specify more than
one column, you must separate the column names with commas.
-
FORMAT, the name of the format that you want to apply.
-
w, the width that you want to use with the format.
-
d, the number of decimal places (if any) to include with numeric
formats.
The order
in which the columns are listed in the string does not affect the
order in which they are returned by an ADO Recordset object.
For example, assume
that a data set has three variables that appear in the following order:
-
SALEDATE
, a SAS date with a default format of MMMYY
-
QUANTITY
, a SAS numeric value with no default format
-
PRICE
, a SAS numeric value with no default format
The following
string value is based on the sample data set:
SALEDATE=MMDDYY8.,+PRICE=DOLLAR8.2
The results appear
in the following four columns on the ADO Recordset object:
-
SALEDATE
, a string column with the MMDDYY8. format
applied
-
QUANTITY
, a numeric column with no format applied
-
PRICE
, a numeric column with no format applied
-
PRICE_DOLLAR8.2
as a string column with the DOLLAR8.2
format applied.
Note: The fourth
column is constructed through the use of the + modifier; it is not
persisted beyond the life of its exposure on the ADO Recordset object.