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

i am using this library "LibABC" which contains many datasets in an unix server. some datasets in this library are zipped (for ex- file1.sas7bdat.Z) and some are unzipped(file2.sas7bdat).

i am not able to access those zipped datasets from the server through my sas code.

kindly help me how can i resolve this issue.

if there is any code in sas to access zipped files from unix server share it with me

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

.Z is the extension used by the compress command, not ZIP or GZIP.

Use the uncompress command to expand the file and then SAS will be able to read it.

 

Editor's note: included some additional details from SAS support doc:

Here's a SAS Note with an example (which assumes the data was compressed via SAS and the compress command). It relies on FILENAME PIPE, which will require privileges to run shell commands (XCMD):

 

Creating the compressed data set: http://support.sas.com/kb/25/199.html

Reading the compressed data set: http://support.sas.com/kb/25/214.html

 

View solution in original post

9 REPLIES 9
kuridisanjeev
Quartz | Level 8

Hi,

Hope this helps.

http://www2.sas.com/proceedings/sugi31/155-31.pdf.

Regards,

Sanjeev.K

naziya
Calcite | Level 5

Sanjeev,

i am not allowed to install any additional tools or software , the pdf u wanted me to refer suggests installation of some tools. So can you suggest if there is some piece of code to unzip files in sas.

kuridisanjeev
Quartz | Level 8

Hi ,

Generally I do use bellow method to read data in zip format.

FILENAME ZIPFILE SASZIPAM 'C:\Users\sanjeev\Desktop\t.zip';

DATA mydata;

  INFILE ZIPFILE(t.txt) DLM=',' FIRSTOBS=2;

  INPUT var1 $ var2 $ var3 $ var4;

RUN;

You can apply the same for your scenario.

Thanks,

Sanjeev.K

Patrick
Opal | Level 21

I had mixed experiences with SASZIPAM in the past. New with SAS 9.4 is a zip engine available (filename myfile zip ....).

I've done some "Googling" as I didn't know what the file extension .Z stands for and found the following File Extension Z « Avanquest

It appears that GZIP is eventually able to deal with it. Ideally the person who created the .Z file tells you what tool they've used and you're using the same to un-compress the data sets.

The exact syntax you need to use - eg. for GZIP - is something you need to look up, but the general principle is as described under the link posted (http://www2.sas.com/proceedings/sugi31/155-31.pdf)

.

PaigeMiller
Diamond | Level 26

Another possibility:

http://www.lexjansen.com/phuse/2006/cc/cc01.pdf

--
Paige Miller
Tom
Super User Tom
Super User

.Z is the extension used by the compress command, not ZIP or GZIP.

Use the uncompress command to expand the file and then SAS will be able to read it.

 

Editor's note: included some additional details from SAS support doc:

Here's a SAS Note with an example (which assumes the data was compressed via SAS and the compress command). It relies on FILENAME PIPE, which will require privileges to run shell commands (XCMD):

 

Creating the compressed data set: http://support.sas.com/kb/25/199.html

Reading the compressed data set: http://support.sas.com/kb/25/214.html

 

naziya
Calcite | Level 5

thanks all

Patrick
Opal | Level 21

If this is resolved for you then could you please mark this question as answered?

CCW
Obsidian | Level 7 CCW
Obsidian | Level 7

I searched for the method for our purpose and the best answer I got for a dumb programer like me is from a SAS paper, Paper 057-2012
A SAS® Macro to Zip and Unzip Files in MS Windows without Additional External Data Archiving Software, Kai Koo, Abbott Laboratories, Santa Clara, CA

The paper is attached if you don't want to search it online.

 

I can skip the concept of this method and just use its macro program. It becomes extremely easy and useful. Hope you like it.

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