General form, DATASETS
procedure with the IC CREATE statement:
PROC DATASETS LIB=libref <NOLIST>;
MODIFY SAS-data-set;
IC
CREATE constraint-name=constraint
<MESSAGE='Error
Message'>;
QUIT;
libref
is the library in which
the data set is stored. If you do not specify the LIB= option, the
procedure uses the Work library.
NOLIST
suppresses the directory
listing.
SAS-data-set
is the name of the
data set to which you want to apply the integrity constraint.
constraint-name
is any name that you
want to give the integrity constraint.
constraint
is the type of constraint
that you are creating, specified in the following format:
Error Message
is an optional message
written to the log when the constraint is violated.
|
proc datasets nolist; modify capinfo; ic create PKIDInfo=primary key(routeid) message='You must supply a Route ID Number'; ic create Class1=check(where=(cap1st<capbusiness or capbusiness=.)) message='Cap1st must be less than CapBusiness'; quit;
45 modify capinfo; 46 ic create PKIDInfo = primary key (routeid) 47 message = 'You must supply a Route ID Number'; NOTE: Integrity constraint PKIDInfo defined. 48 ic create Class1 = check (where = (cap1st < capbusiness 49 or capbusiness = .)) message = 'Cap1st must be less 50 than CapBusiness'; NOTE: Integrity constraint Class1 defined. 51 run; |
data capinfo; modify capinfo; cap1st=cap1st*3; run;
FlightID=IA00100 RouteID=0000001 Origin=RDU Dest=LHR Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=1 FlightID=IA00201 RouteID=0000002 Origin=LHR Dest=RDU Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=2 FlightID=IA00300 RouteID=0000003 Origin=RDU Dest=FRA Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=3 FlightID=IA00400 RouteID=0000004 Origin=FRA Dest=RDU Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=4 FlightID=IA02900 RouteID=0000029 Origin=SFO Dest=HNL Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=29 FlightID=IA03000 RouteID=0000030 Origin=HNL Dest=SFO Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=30 FlightID=IA03300 RouteID=0000033 Origin=RDU Dest=ANC Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=33 FlightID=IA03400 RouteID=0000034 Origin=ANC Dest=RDU Cap1st=42 CapBusiness=30 CapEcon=163 _ERROR_=1 _IORC_=660130 _N_=34 NOTE: There were 50 observations read from the data set WORK.CAPINFO. NOTE: The data set WORK.CAPINFO has been updated. There were 42 observations rewritten, 0 observations added and 0 observations deleted. NOTE: There were 8 rejected updates, 0 rejected adds, and 0 rejected deletes. |