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

Hey!

 

I have a process that identifies datasets that can be compressed to safe storage space. I would like to loop through these datasets and compress them but I want to keep the owner and date fields unchanged.

 

Essentially, my current code moves the dataset from its current location to work then back to its original location. I'm able to keep the original date values but this approach results in the owner value switching to me. My goal is to keep all the original metadata just compress the dataset. 

 

Below is an example of my code:

Options Compress = Yes;

Libname Cleanup '/cidata/pmgshr/lob_gl/202106/SAS_Ref';

Proc Datasets Library = Cleanup NoList;
Copy In = Cleanup Out = Work NoClone DateCopy Move;
Select LOSS_DEV_SMOOTH
PREM_DEV
PREM_WLDD
;
Run;
Copy In = Work Out = Cleanup NoClone DateCopy Move;
Select LOSS_DEV_SMOOTH
PREM_DEV
PREM_WLDD
;
Run;
Quit;

Libname Cleanup Clear;

Options Compress = No;

 

Thanks for the help!

-rileyd

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@rileyd wrote:

I don't think that's the case. My current code works just fine with the exception of the value of the original owner/creator of the dataset changing.


Like @SASKiwi states the SAS files get re-created. The owner of the new file is the owner of the process that creates the files (which is you or a functional user if run under a scheduler).

Creating/changing the owner of a file requires elevated rights which you highly likely won't have and won't get. IF you'd have such elevated rights then the owner could get changed with Unix OS commands after the new file has been created.

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

Not possible. To compress SAS datasets they have to be rewritten in their entirety, row by row as in a DATA step:

data Compressed (compress = yes);
  set Not_Compressed;
run;
rileyd
Quartz | Level 8

I don't think that's the case. My current code works just fine with the exception of the value of the original owner/creator of the dataset changing.

Patrick
Opal | Level 21

@rileyd wrote:

I don't think that's the case. My current code works just fine with the exception of the value of the original owner/creator of the dataset changing.


Like @SASKiwi states the SAS files get re-created. The owner of the new file is the owner of the process that creates the files (which is you or a functional user if run under a scheduler).

Creating/changing the owner of a file requires elevated rights which you highly likely won't have and won't get. IF you'd have such elevated rights then the owner could get changed with Unix OS commands after the new file has been created.

SASKiwi
PROC Star

Your code will work but have you checked if your datasets are compressed or not? When I tested PROC DATASETS COPY it didn't compress.

 

EDIT: Using NOCLONE ensures the target dataset is compressed. Don't think there is any way to prevent metadata being updated.

rileyd
Quartz | Level 8
Yes, they're compressed. You need to include the Options statement before and after the Proc Datasets block of code. My hope was that there was an option to keep the original owner/creator value as the DateCopy option does for the date metadata values.
SASKiwi
PROC Star

Agree. Just found NOCLONE is required too to go from uncompressed to compressed. Don't know any way to avoid the metadata update.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 833 views
  • 0 likes
  • 3 in conversation