私は SAS 4GL の初心者です...
主キーまたは複合主キーの一部である列をテーブルから抽出することは可能ですか? それらの値を出力データセットの 1 つの列にマージする必要があります。
問題は、入力としてさまざまなテーブルを取得でき、それらの定義がわからないことです。
私は SAS 4GL の初心者です...
主キーまたは複合主キーの一部である列をテーブルから抽出することは可能ですか? それらの値を出力データセットの 1 つの列にマージする必要があります。
問題は、入力としてさまざまなテーブルを取得でき、それらの定義がわからないことです。
インデックスが定義されている場合、そのインデックスで使用されている変数を見つけることができます。例を参照してください。
data blah(index=(name));
set sashelp.class;
run;
proc contents data=blah out=blahconts;
run;
blahconts
name
が単純なインデックスにあり、合計 1 つのインデックスがあることを示す列があります。
また、次のSAS ドキュメントの例のように、外部キー制約を設定することもできます。
proc sql;
create table work.mystates
(state char(15),
population num,
continent char(15),
/* contraint specifications */
constraint prim_key primary key(state),
constraint population check(population gt 0),
constraint continent check(continent in ('North America', 'Oceania')));
create table work.uspostal
(name char(15),
code char(2) not null, /* constraint specified as */
/* a column attribute */
constraint for_key foreign key(name) /* links NAME to the */
references work.mystates /* primary key in MYSTATES */
on delete restrict /* forbids deletions to STATE */
/* unless there is no */
/* matching NAME value */
on update set null); /* allows updates to STATE, */
/* changes matching NAME */
/* values to missing */
quit;
proc contents data=uspostal out=postalconts;
run;
proc sql;
describe table constraints uspostal;
quit;
これにより、制約情報が出力ウィンドウに書き込まれます。出力データセットから、変数が単純なインデックスにあることがわかります。PROC CONTENTS
これらのいずれか (またはDESCRIBE TABLE CONSTRAINTS
) を ODS OUTPUT でラップして、情報をデータセットに取得できます。
ods output IntegrityConstraints=postalICs;
proc contents data=uspostal out=postalconts;
run;
ods output close;
また
ods output IntegrityConstraints=postalICs;
proc sql;
describe table constraints uspostal;
quit;
ods output close;