[英]How do I set Primary Key | SAS Studio
I'm trying to set Primary Key on SAS and I keep getting the error mentioned below.我正在尝试在 SAS 上设置主键,但我不断收到下面提到的错误。 Any help would be great!任何帮助都会很棒!
The first snippet is code and the next is the error.第一个片段是代码,下一个是错误。
/*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**
The error I get -我得到的错误 -
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.
Remove work.
删除work.
from your modify statement.从您的修改声明中。 The lib=
option specifies the library. lib=
选项指定库。 It's a quirk of proc datasets
.这是proc datasets
的一个怪癖。
proc datasets lib=work;
modify FinAdvMaster;
ic create primary key (FinAdvID);
quit;
Note that this key will be destroyed if you recreate the dataset.请注意,如果您重新创建数据集,此密钥将被销毁。
You can use SQL to add a column constraint specifying PRIMARY KEY
您可以使用 SQL 添加指定PRIMARY KEY
的列约束
Example:例子:
proc sql;
create table work.class as select * from sashelp.class;
alter table work.class add constraint pk_name primary key(name);
In your case在你的情况下
alter table FinAdvMaster
add constraint
pk_FinAdvID primary key(FinAdvID)
;
pk_ <column-name>
is a common convention for naming primary keys. pk_ <column-name>
是命名主键的常用约定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.