About Format and Informat Processing with OLE DB

What Are Formats and Informats?

A SAS format is a pattern or set of instructions that SAS uses to determine how the values of a variable (or column) should be written or displayed. A SAS informat is a pattern or set of instructions that SAS uses to determine how data values in an input file should be interpreted. SAS provides a set of standard formats and informats and also enables you to define your own.
OLE DB applications use customizations to the OLE DB interfaces in order to access SAS formatting features. The following topics explain how to use the customizations in your application:
Note: ADO applications support SAS formatting features through the use of the "SAS Formats" and "SAS Informats" properties. For more information, see Using SAS Formats When You Read Data and Using SAS Informats When You Write Data.

Supported SAS Formats

The level of support for SAS formats depends on the provider:
  • The IOM provider supports both user-written formats and SAS formats that are defined within the context of the currently active IOM workspace.
  • The local provider, OLAP provider, and SAS/SHARE provider do not support user-written formats; however, they do support most SAS formats.
Note: The OLAP provider requires that the formats are persisted with the cube on the OLAP server. For more information, see Determining Persisted (Default) Formatting Information.
Here is the list of supported SAS formats:
$ASCII DOWNAME NUMX S370FZDT
$BINARY DTDATE OCTAL S370FZDU
$CHAR DTMONYY PD TIME
$EBCDIC DTYEAR PERCENT TIMEAMPM
$HEX DTYYQC PIB TOD
$OCTAL E PIBR WEEKDATE
$QUOTE FLOAT PK WEEKDATX
$REVERJ FRACT PVALUE WEEKDAY
$REVERS HEX QTR WORDDATE
$UPCASE HHMM QTRR WORDDATX
$XPORTCH HOUR RB WORDF
BEST IB ROMAN WORDS
BINARY IEEE SSN XYYMMDD
COMMA JULIAN S370FF YEAR
COMMAX MINGUO S370FIB YEN
D MMDDYY S370FIBU YYMM
DATEAMPM MMSS S370FPD YYMMDD
DATETIME MMYY S370FPDU YYMMN
DATE MONNAME S370FPIB YYMON
DAY MONTH S370FRB YYQ
DDMMYY MONYY S370FZD YYQR
DOLLAR NEGPAREN S370FZDL Z
DOLLARX NENGO S370FZDS ZD
For more information about SAS formats, see the SAS Language Reference: Dictionary.

Determining Persisted (Default) Formatting Information

In a SAS data set, a variable (column) can have persisted (default) formatting information. There are two methods that you can use to determine what, if any, default formatting information exists in a data set. Use the method that is most appropriate for your application.
  • Along with some other column metadata that is specific to SAS, the ISASColumnsInfo customized rowset interface returns the names, lengths, and decimal widths of formats and informats that are stored in the data set. In order to use the interface, the data set must be open. For more information about how to use the interface, see ISASColumnsInfo Custom Interface.
Note: A format or informat name that is returned by ISASColumnsInfo::GetColumnsInfo might not be supported by a particular provider or server. By default, you will receive an error if you attempt to apply format or informat services with a format that is not supported. To change this default behavior, set the DBPROP_SAS_FMTERR property to VARIANT_FALSE.
  • The COLUMNS schema rowset also returns format and informat metadata. Consider using this method if your application needs to determine metadata for columns that exist in a table that is not open. For more information, see COLUMNS Schema Rowset.