DATA Step, Macro, Functions and more

A question on SAS indexes

Reply
N/A
Posts: 0

A question on SAS indexes

Hi,

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.

Thank you very much.

Sars
N/A
Posts: 0

Re: A question on SAS indexes

Posted in reply to deleted_user
You can read about Rename statement in Proc Datasets
http://support.sas.com/documentation/cdl/en/proc/59565/PDF/default/proc.pdf
page 338
N/A
Posts: 0

Re: A question on SAS indexes

Posted in reply to deleted_user
Thanks...will surely read it soon.
Super Contributor
Posts: 260

Re: A question on SAS indexes

Posted in reply to deleted_user
Hi.
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).
[pre]
PROC COPY IN=sashelp OUT=work ;
SELECT class ;
RUN ;
PROC SQL ;
CREATE INDEX name ON work.class ;
QUIT ;
PROC DATASETS LIB = work NOLIST ;
MODIFY class ;
RENAME name = first ;
RUN ; QUIT ;
PROC CONTENTS DATA = work.class ;
RUN ;
PROC SQL ;
DESCRIBE TABLE work.class ;
QUIT ;
[/pre]
Both SQL and CONTENTS show that the index is still available, now attached to the renamed variable.
Regards
Olivier
N/A
Posts: 0

Re: A question on SAS indexes

Thank you for the explanation. It is really helpful.
Ask a Question
Discussion stats
  • 4 replies
  • 156 views
  • 0 likes
  • 2 in conversation