DBNULL= Data Set Option

When a table is created, this option indicates whether a null is a valid value for the specified columns.
Valid in: DATA and PROC steps
Default: data source-specific
Supports: DB2 UNIX/PC, Greenplum, MySQL, ODBC, Oracle, Teradata

Syntax

DBNULL=<_ALL_=YES | NO > | ( <column-name-1=YES | NO > <…<column-name-n=YES | NO > > )

Syntax Description

_ALL_
specifies that the YES or NO applies to all columns in the table. (This is valid for Oracle and Teradata only.)
YES
specifies that a null is not valid for the specified columns in the table.
NO
specifies that a null is not valid for the specified columns in the table.

Details

This option is valid only when you are creating tables. If you specify more than one column name, the names must be separated with spaces.
The DBNULL= option processes values from left to right, so if you specify a column name twice, or if you use the _ALL_ value, the last value overrides the first value that is specified for the column.

Examples

Example 1: Prevent Specific Columns from Accepting Null Values

In the following example, by using the DBNULL= option, the EMPID and JOBCODE columns in the new MYDBLIB.MYDEPT2 table are prevented from accepting NULL values. If the EMPLOYEES table contains NULL values in the EMPID or JOBCODE columns, the DATA step fails.
data mydblib.mydept2(dbnull=(empid=no jobcode=no));
   set mydblib.employees;
run; 

Example 2: Prevent All Columns from Accepting Null Values

In the following example, all columns in the new MYDBLIB.MYDEPT3 table except for the JOBCODE column are prevented from accepting NULL values. If the EMPLOYEES table contains NULL values in any column other than the JOBCODE column, the DATA step fails.
data mydblib.mydept3(dbnull=(_ALL_=no jobcode=YES));
   set mydblib.employees;
run;