I have started preparing for advanced SAS certification, and I have a question regarding SAS indexes.
I created an index (named Patient) of the unique variable 'Patient' on sasuser.heart dataset. The log confirms this. Later on I renamed the variable 'Patient' to 'Pid' just to see what happens to the index I created. I tried describe table statement to get some insight into this, and it does write a create table to the log, but I am unable to come to any conclusion.
Can someone pls tell me what happens in this case?
I have read while googling that 'Events such as using an indexed SAS dataset as input to Data or Proc Step, renaming indexed key variables, renaming indexed sas dataset, and updating the indexed sas dataset via the Key option on the Modify statement have no adverse effect on the indexed dataset'.
So my question is, after renaming the key variable, in what shape does my original index exist?
I am mainly following SAS Preparation guide for my exam, and I did not get an answer to this.
I think that your index is still in good shape, if you renamed the variable outside a Data step (which would erase and rebuild the table, hence delete the index).
PROC COPY IN=sashelp OUT=work ;
SELECT class ;
PROC SQL ;
CREATE INDEX name ON work.class ;
PROC DATASETS LIB = work NOLIST ;
MODIFY class ;
RENAME name = first ;
RUN ; QUIT ;
PROC CONTENTS DATA = work.class ;
PROC SQL ;
DESCRIBE TABLE work.class ;
Both SQL and CONTENTS show that the index is still available, now attached to the renamed variable.