Desktop productivity for business analysts and programmers

keep Indexes while overwriting an idexed data set.

Reply
Occasional Contributor
Posts: 7

keep Indexes while overwriting an idexed data set.

[ Edited ]

Hi everyone, I wondered  if the index is kept while overwriting an indexed data set ?

 

for example:

 

data MyIndexedTable;

   set MyIndexedTable;

   newColumn=2*oldColumn;

run;

 

If it is not possible to keep indexes that way, how can I manage to update my table by keeping its indexes ?

Thanks in advance !

Super User
Posts: 10,574

Re: keep Indexes while overwriting an idexed data set.


@Dozo92i wrote:

Hi everyone, I wondered  if the index is kept while overwriting an indexed data set ?

 

for example:

 

data MyIndexedTable;

   set MyIndexedTable;

   newColumn=2*oldColumn;

run;

 

If it is not possible to keep indexes that way, how can I manage to update my table by keeping its indexes ?

Thanks in advance !


Try it.

Run a proc contents before and after, and you'll have the answer.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 10,574

Re: keep Indexes while overwriting an idexed data set.

Posted in reply to KurtBremser

Example code for the test:

data work.class;
set sashelp.class;
run;

proc datasets library=work nolist;
modify class;
index create sex;
run;
quit;

proc contents data=work.class;
run;

data work.class;
set sashelp.class;
run;

proc contents data=work.class;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 5,917

Re: keep Indexes while overwriting an idexed data set.

Data step with MODIFY would work.
Perhaps SQL UPDATE as well.
Not sure though if this will perform as fast as data step SET and rebuild index.
Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 170 views
  • 2 likes
  • 3 in conversation