BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidCaliman
Calcite | Level 5

When i use the command below, a new table is generated, however the sas index file is not generated.

proc sql;

create table x (compress=char) as select * from y;

** y has a index file

Is there some command to create a table from another, generating the index file?

I have some tables that are becoming very large because of deletes operations.

SAS has not command to rebuild a table, so I need to do this recreation once a week automatically, and should not fail if you create a new field in the table, for example.

1 ACCEPTED SOLUTION

Accepted Solutions
snoopy369
Barite | Level 11

First off, you can just rebuild the index, of course.  If you're deleting significant numbers of records, you probably should do that anyway. 

Secondly, PROC COPY will copy indexes AND will remove empty space.  However, in addition to the warning that preserving indexes isn't great when a lot of rows are being removed, it also requires you to copy from one library to another.  Perhaps there's a way around that, I'm not sure.

I assume your concern here is that the index file itself may have been changed?  Otherwise this is fairly straightforward (ie, option 1).

-Joe

View solution in original post

4 REPLIES 4
snoopy369
Barite | Level 11

First off, you can just rebuild the index, of course.  If you're deleting significant numbers of records, you probably should do that anyway. 

Secondly, PROC COPY will copy indexes AND will remove empty space.  However, in addition to the warning that preserving indexes isn't great when a lot of rows are being removed, it also requires you to copy from one library to another.  Perhaps there's a way around that, I'm not sure.

I assume your concern here is that the index file itself may have been changed?  Otherwise this is fairly straightforward (ie, option 1).

-Joe

Ksharp
Super User

The following could work ?

proc sql;

create table x (compress=char index=xx) as select * from y;

CTorres
Quartz | Level 8

Yes, it works. See below:

proc sql noprint;

  create table class(compress=char index=(name)) as select * from sashelp.class;

quit;

CTorres

DavidCaliman
Calcite | Level 5

I used the following and it works:

proc copy in=lib1 out=lib2 CONSTRAINT=YES INDEX=YES;

select y;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2931 views
  • 3 likes
  • 4 in conversation