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
@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.
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;
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.
@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.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.