[英]How do I set Primary Key | SAS Studio
我正在嘗試在 SAS 上設置主鍵,但我不斷收到下面提到的錯誤。 任何幫助都會很棒!
第一個片段是代碼,下一個是錯誤。
/*Primary Key*/ /*Defines the unique key*/
Proc datasets lib=work;
modify WORK.FinAdvMaster;
ic create primary key(FinAdvID);
PROC PRINT DATA=WORK.FinAdvMaster; RUN;**strong text**
我得到的錯誤 -
96 /*Primary Key*/ /*Defines the unique key*/
97
98 Proc datasets lib=work;
99 modify WORK.FinAdvMaster;
_________________
22
201
ERROR 22-322: Expecting a name.
ERROR 201-322: The option is not recognized and will be ignored.
100 ic create primary key(FinAdvID);
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
刪除work.
從您的修改聲明中。 lib=
選項指定庫。 這是proc datasets
的一個怪癖。
proc datasets lib=work;
modify FinAdvMaster;
ic create primary key (FinAdvID);
quit;
請注意,如果您重新創建數據集,此密鑰將被銷毀。
您可以使用 SQL 添加指定PRIMARY KEY
的列約束
例子:
proc sql;
create table work.class as select * from sashelp.class;
alter table work.class add constraint pk_name primary key(name);
在你的情況下
alter table FinAdvMaster
add constraint
pk_FinAdvID primary key(FinAdvID)
;
pk_ <column-name>
是命名主鍵的常用約定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.