32 %macro mp_createconstraints(inds=mp_getconstraints
33 ,outds=mp_createconstraints
37 proc sort data=&inds out=&outds;
38 by libref table_name constraint_name;
43 by libref table_name constraint_name;
44 length create_statement $500;
45 if _n_=1 and
"&execute"=
"YES" then call execute(
'proc sql;');
46 if first.constraint_name then
do;
47 if constraint_type=
'PRIMARY' then type=
'PRIMARY KEY';
48 else type=constraint_type;
49 create_statement=catx(
" ",
"alter table",libref,
".",table_name
50 ,
"add constraint",constraint_name,type,
"(");
51 if last.constraint_name then
52 create_statement=cats(create_statement,column_name,
");");
53 else create_statement=cats(create_statement,column_name,
",");
54 if "&execute"=
"YES" then call execute(create_statement);
56 else if last.constraint_name then
do;
57 create_statement=cats(column_name,
");");
58 if "&execute"=
"YES" then call execute(create_statement);
61 create_statement=cats(column_name,
",");
62 if "&execute"=
"YES" then call execute(create_statement);