BookmarkSubscribeRSS Feed
☑ This topic is solved. 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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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