Padding Character Data with Blanks

Goal

You want your application to preserve trailing blanks.
This recipe applies to the local, SAS/SHARE, IOM, and Base SAS providers. Sample code for ADO is included.

ADO Implementation

By default, the SAS providers trim trailing blanks from character columns. This behavior differs from the default SAS DATA step behavior in which trailing blanks are preserved. To force the SAS providers to preserve trailing blanks, set the "SAS Preserve Trailing Blanks" property to True. The following sample Visual Basic code shows how this task is done.
' obConnection is an open Connection object.
Dim obRecordset As New ADODB.Recordset

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

' The second parameter on the Open method must remain empty.
obRecordset.Open "sashelp.shoes", , adOpenStatic, adLockReadOnly, adCmdTableDirect

OLE DB Implementation

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