1

I am trying to create and insert date data into table in SAS but I get this error message.

proc sql;

alter table a2db.student add dob DATETIME format=datetime20.;
insert into a2db.student (dob) values ('1Sep2015:0:0:0'dt);

ERROR: Add/Update failed for data set A2DB.STUDENT because data value(s) do not comply with integrity constraint NM0002.

The column is created but the error occurs at insert command.

Lucy Hong
  • 91
  • 8

1 Answers1

0

If you run proc sql;describe table a2db.student and check the log, you will find that your table has index or key constraints. The row you are adding has just one value (for dob) so the missing values in the remaining columns are triggering the constraint warning.

It's probably a primary key (which is UNIQUE and NOT NULL by default).

Be sure to pass a full row of data when running an insert.

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124