Skip to content

Instantly share code, notes, and snippets.

@statgeek
Created November 10, 2023 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/c88586561ba3d120844c350f4ef3145c to your computer and use it in GitHub Desktop.
Save statgeek/c88586561ba3d120844c350f4ef3145c to your computer and use it in GitHub Desktop.
SAS - Read a zipped xpt file into SAS
*path to the zip file;
filename src zip "/home/fkhurshed/Demo2/P_DR2IFF.zip";
*path to where to save the xpt file;
filename xl "/home/fkhurshed/Demo2/P_DR2IFF.xpt" ;
*extract file from zip - P_DR2IFF.XPT in the code below is the name of the file in the zipped file that is to be extracted;
data _null_;
/* using member syntax here */
infile src(P_DR2IFF.XPT)
lrecl=256 recfm=F length=length eof=eof unbuf;
file xl lrecl=256 recfm=N;
input;
put _infile_ $varying256. length;
return;
eof:
stop;
run;
*where to store the SAS dataset;
libname projfile '/home/fkhurshed/Demo2/';
*XPT file (same as filename xl as above);
libname xptfile xport '/home/fkhurshed/Demo2/P_DR2IFF.xpt' access=readonly;
*extract the SAS dataset from the XPT file;
proc copy inlib=xptfile outlib=projfile;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment