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/
My mistake. %GDIR() is the name of my local macro to call that function. The actual function is PATHNAME().
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.
My mistake. %GDIR() is the name of my local macro to call that function. The actual function is PATHNAME().
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.