I have tables that I want to set its own primary key and index.
Most of the tables will use ID/RK as Primary Key whereas index will be ID/RK + STARTDT
In SAS Data Integration Studio, setting ID/RK as primary key will also auto set ID/RK as index. If I want to set STARTDT as one of the indexes, it will prompt error saying primary key doesn't have STARTDT as key bla bla. I can provide the exact error message if you need. Only if i set STARTDT as primary key, index will auto include STARTDT.
This is not what I want. If i copy the auto generated code from SAS DI and paste it in EG, i can set as below by executing script in SAS EG with slight modification on my own:
Primary key: ID/RK
Index: ID/RK + STARTDT
In DI Studio, there is no way for me to have Primary key as ID/RK while having ID/RK + STARTDT as index.
Or is there anyway or workaround for me to do so in SAS DI Studio?
There is no point whatsoever in adding another variable to create a composite index that includes a unique variable.
The unique variable identifies the one record to retrieve. The other variable serves no purpose.
I don't know what you are trying to achieve,
All this code is valid:
data CLASS;
set SASHELP.CLASS;
run;
proc sql;
alter table CLASS add primary key(SEX,NAME);
quit;
proc contents ; run;
data CLASS;
set SASHELP.CLASS;
run;
proc sql;
alter table CLASS(index=(A=(NAME SEX))) add primary key(NAME);
quit;
proc contents ; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.