Resources

Padding Character Data with Blanks

In this recipe, you learn how to force the SAS Data Providers to preserve trailing blanks. Sample code for the ADO recipe is included.

Applies to: SAS Local Data Provider, SAS/SHARE Data Provider, SAS IOM Data Provider
Implement using: ADO or OLE DB

Overview

By default, the SAS Data Providers trim trailing blanks from character columns. This differs from the default SAS DATA step behavior in which trailing blanks are preserved. To use ADO to force the SAS Data Providers to preserve trailing blanks, set the "SAS Preserve Trailing Blanks" property to True, as shown in the following example. (In this example, the connection is already open. For information about how to open a Connection object, see Opening an ADO Connection Object.)


obRecordset.ActiveConnection = obConnection 
obRecordset.Properties("SAS Preserve Trailing Blanks") = True

'Note that obRecordset.ActiveConnection was set above and
'therefore no Connection is passed to the Open call

obRecordset.Open "sashelp.shoes", , adOpenStatic, adLockReadOnly, adCmdTableDirect

Note: The second parameter must remain empty, as shown in the code fragment.


Details

When writing to the ADO interface, the value of the customized rowset property "SAS Preserve Trailing Blanks" determines whether or not the provider trims trailing blanks from character values. The default value is False, which causes the provider to trim blanks unless you specify otherwise. If you set this value to True, the provider will preserve trailing blanks.

When writing to the OLE DB interface, use DBPROP_SAS_BLANKPADDING (a member of the DBPROPSET_SAS_ROWSET property set) to control this behavior.