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

Hi,

I would like to read from a gzip SAS dataset into my program. I use the following, but I am not getting back any results:

 

filename rx_clm ZIP "/nfs/sasarch/MI/hedis/hedis_vendor/production/inovalon/my2020/inovalon/data/extract/rx/rx_clm_ext_202104.sas7bdat.gz" GZIP;

 

This is my understanding after reading the post in SAS Support. Am I understanding incorrectly?

https://blogs.sas.com/content/sasdummy/2017/10/10/reading-writing-gzip-files-sas/

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

My mistake. %GDIR() is the name of my local macro to call that function. The actual function is PATHNAME().

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

The FILENAME statement is just to create a pointer to the file, call a FILEREF.  To actually read from the file you need to have other code that references the fileref the FILENAME statement created.

 

The article you linked to is about reading from a text file.  From the name that appears to be an actual SAS dataset, which is a binary file,  so you need to actually convert it into an uncompressed file for SAS to be able to use it.

 

Here is code that will use FCOPY() function to copy it as a binary file into a file in the WORK directory.

filename rx_clm ZIP 
  "/nfs/sasarch/MI/hedis/hedis_vendor/production/inovalon/my2020/inovalon/data/extract/rx/rx_clm_ext_202104.sas7bdat.gz" 
  GZIP   recfm=f lrecl=512
;
filename out "%sysfunc(pathname(work))/rx_clm_ext_202104.sas7bdat" recfm=f lrecl=512;

%let rc=%sysfunc(fcopy(rx_clm,out)); 

From there you can work with it using normal SAS code.  For example to see what variables it has run PROC CONTENTS on it.

proc contents data=work.rx_clm_ext_202104;
run;

Edited: Fixed function to get location of work directory.

Jesusismygrace
Obsidian | Level 7
Thank you for your knowledgeable response and example. I ran you code and received the following error message:

ERROR: The GDIR function referenced in the %SYSFUNC or %QSYSFUNC macro function is not found.
Tom
Super User Tom
Super User

My mistake. %GDIR() is the name of my local macro to call that function. The actual function is PATHNAME().

Jesusismygrace
Obsidian | Level 7
Thank you and have a great day

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1563 views
  • 2 likes
  • 2 in conversation