SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How do I zip a SAS data set?

Accepted Solution Solved
Reply
Contributor n6
Contributor
Posts: 65
Accepted Solution

How do I zip a SAS data set?

 

I have a folder named CSmiley IndifferentFolder.  And I put a SAS dataset in it named ABC.sas7bdat.

 

The person I created it for wants to send it over email but it's too big so I've been tasked with zipping it.  I thought this would be simple but fruistratingly it is not.  (Is "frustratingly" a word?  It is now.)

 

I thought I'd be able to just right click the dataset or perhaps recreate it while adding an option to the DATA statement.  But those don't work and instead my research is bringing up all sorts of SAS code and I'm trying them but while some steps work others do not.

 

Any ideas for a simple way to do this are greatly appreciated.


Accepted Solutions
Solution
Wednesday
Valued Guide
Posts: 540

Re: How do I zip a SAS data set?

Glad to hear I pointed you in the right direction. If your dataset contains predominantly numeric data you may obtain a higher compression rate by using BINARY compression. Give this a try:

 

libname xyz "C;\";

data xyz.abc_compressed (compress=binary);

   set xyz.abc;

run;

 

Also note how I added code: use the running man or the {i} icon.

 

You may get even more compression by using a Windows zip utility. It is still unclear to us why that wouldn't work.

 

Hope this helps,

-- Jan.

 

View solution in original post


All Replies
Contributor n6
Contributor
Posts: 65

Re: How do I zip a SAS data set?

 

That first line should be a C, then a colon, then a backslash, then "Folder."  I was trying to make it the simplest possible situation.  I guess they sometimes turn stuff with a colon into an emoji.

Valued Guide
Posts: 540

Re: How do I zip a SAS data set?

When you say "those don't work", what happened? Where did zipping a file go wrong? keep in mind that zipping is a task executed in the operating system, in your case most likely in the Explorer. There is little reason why this wouldn't work. I can think of the file being locked by SAS (eg. open in a table viewer or a running proc) or Windows not granting you the required access. Please enlighten us!

 

In SAS a dataset can be compressed with roughly similar compression factor but keeping the structure in tact and directly accessible by SAS. Use the COMPRESS=YES (or COMPRESS=BINARY) option when creating or copying the table. Have a look at the doc for more details about dataset compression. The resulting .sas7bdat file should be considerably smaller, although your mileage may vary.

 

Hope this helps,

-- Jan

Contributor n6
Contributor
Posts: 65

Re: How do I zip a SAS data set?

Posted in reply to jklaverstijn

I finally figure it out shortly before I got the e-mail telling me that you posted.  In a couple places I used a semicolon instead of a colon because a colon yields an emoji.  I think you can put any name in place of ClinicalProjectZip but that's what they used in the documentation I was using to try to figure it out, so I kept it.

 

ODS PACKAGE (ClinicalProjectZIP) OPEN nopf;
ODS PACKAGE (ClinicalProjectZIP) ADD file = "C;\ABC.sas7bdat";
ODS PACKAGE (ClinicalProjectZIP) PUBLISH archive
PROPERTIES (archive_name = "ABC.zip"
                         archive_path = "C;\" );
ODS PACKAGE (ClinicalProjectZIP) CLOSE;

 

But yeah, this would be much easier.

 

libname xyz "C;\";

data xyz.abc_compressed (compress=yes);

   set xyz.abc;

run;

 

I figured something like that must exist but I didn't know what it was.  I looked at the documentation for the DATA statement but I was only looking for a ZIP option and thus I overlooked the COMPRESS option.  That said though, I just made it with COMPRESS and it looks like it's still about half the size of the original.  I guess that's all the more it gets compressed.

Solution
Wednesday
Valued Guide
Posts: 540

Re: How do I zip a SAS data set?

Glad to hear I pointed you in the right direction. If your dataset contains predominantly numeric data you may obtain a higher compression rate by using BINARY compression. Give this a try:

 

libname xyz "C;\";

data xyz.abc_compressed (compress=binary);

   set xyz.abc;

run;

 

Also note how I added code: use the running man or the {i} icon.

 

You may get even more compression by using a Windows zip utility. It is still unclear to us why that wouldn't work.

 

Hope this helps,

-- Jan.

 

Valued Guide
Posts: 540

Re: How do I zip a SAS data set?

hang on, I just spotted a possible typo in your code:

 

ODS PACKAGE (ClinicalProjectZIP) ADD file = "C;\ABC.sas7bdat";

The semicolon should be a colon:

 

ODS PACKAGE (ClinicalProjectZIP) ADD file = "C:\ABC.sas7bdat";

Maybe that's your problem :-)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 124 views
  • 0 likes
  • 2 in conversation