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

 

I have a folder named C:|Folder.  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.

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

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

5 REPLIES 5
n6
Quartz | Level 8 n6
Quartz | Level 8

 

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.

jklaverstijn
Rhodochrosite | Level 12

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

n6
Quartz | Level 8 n6
Quartz | Level 8

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.

jklaverstijn
Rhodochrosite | Level 12

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.

 

jklaverstijn
Rhodochrosite | Level 12

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 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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