BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bayzid
Obsidian | Level 7

Hi,

I am using the following code to compress all the datasets in a library. But it requires creating a new library to save the compressed files and that is an issue with me due to very large number of files. Is it possible to compress the whole library without saving into a new one?

****Compressing the whole library;

 

options compress=yes;

proc datasets lib=tab nolist;

copy inlib=sas outlib=saso noclone datecopy memtype=data;

run;quit;

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
Opal | Level 21

The only way to do this in place would be DATA steps:

options compress=yes;

data MyLib.MyDataset;
  set MyLib.MyDataset;
run;

EDIT: Maybe you could copy some at a time into your WORK library, then copy back to your permanent library? 

View solution in original post

3 REPLIES 3
SASKiwi
Opal | Level 21

The only way to do this in place would be DATA steps:

options compress=yes;

data MyLib.MyDataset;
  set MyLib.MyDataset;
run;

EDIT: Maybe you could copy some at a time into your WORK library, then copy back to your permanent library? 

bayzid
Obsidian | Level 7

That works for a single dataset. I have ~100k datasets and need to do the entire library at once.

SimonDawson
SAS Employee

You will need a macro loop to iterate over tables in the library. Here is some sample code that might help. You'll need to update the WHERE clause and then add the code that you want into the loop.

 

proc sql;
    select catt(libname,".",memname), count(*)
    into :table1 -, :table_cnt
    from sashelp.vmember
    where libname="WORK" and memtype="DATA";
quit;

%macro myloop;
  %do i = 1 %to &table_cnt;
    %put Working on &&table&i..;

   /* Your code here */

  %end;
%mend;
%myloop;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 189 views
  • 0 likes
  • 3 in conversation