BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
4 REPLIES 4
deleted_user
Not applicable
You can read about Rename statement in Proc Datasets
http://support.sas.com/documentation/cdl/en/proc/59565/PDF/default/proc.pdf
page 338
deleted_user
Not applicable
Thanks...will surely read it soon.
Olivier
Pyrite | Level 9
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
deleted_user
Not applicable
Thank you for the explanation. It is really helpful.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 768 views
  • 0 likes
  • 2 in conversation