SAS Procedures

Help using Base SAS procedures
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3945 views
  • 3 likes
  • 4 in conversation