DB2 data is not displayed correctly or is truncated when you use SAS/ACCESS® Interface to DB2


When you use SAS/ACCESS Interface to DB2 to connect to DB2, you might encounter these issues:

The message appears because the DB2 encoding on the DB2 server does not match the DB2 encoding on the client.

To set the DB2 encoding correctly in SAS/ACCESS Interface to DB2, follow these steps:

  1. Run this query using the DB2 Command Line Processor to determine the value for the DB2CODEPAGE environment variable on the DB2 server:
    SELECT CODEPAGE FROM SYSCAT.DATATYPES WHERE TYPENAME='VARCHAR';
    Take note of the number that is returned and use it as the value for the DB2CODEPAGE environment variable in Step 2.
  2. Set DB2CODEPAGE by following the steps for your operating environment:
    • If SAS/ACCESS Interface to DB2 is installed on a Microsoft Windows system:
      1. Select Start ► Control Panel and click System. Then click Advanced system settings on the left.
      2. In the System Properties dialog box, click the Advanced tab.
      3. Click Environment Variables.
      4. In the System variables section, click New.
      5. In the Variable name field, enter DB2CODEPAGE.
      6. In the Variable value field, enter the value that was returned when you ran the query in Step 1.
    • If SAS/ACCESS Interface to DB2 is installed on a UNIX system:
      1. Open the sasenv_local file, located in !SASROOT/bin.
      2. Add this command to the file:
        export DB2CODEPAGE=DB2CODEPAGE-value
  3. Open a new SAS® session to verify that your data is displayed correctly.