SAS解压单个sas7bdat文件

SAS解压单个sas7bdat文件,sas,zip,compression,unzip,Sas,Zip,Compression,Unzip,我在网上搜遍了,找不到确切的我需要的东西。在SAS程序结束时,我使用ods包方法压缩了最终的数据集(20GB)。我的数据集现在根据需要放在一个压缩文件夹中。现在,我想解压并读入.sas7bdat文件,但我不太确定该方法 下面是一个创建永久SAS数据集并将其压缩的示例。我可以查看该zip文件并“查看”所需的数据集,但我不知道如何解压并读入: ** assign your path **; libname output "H:\SAS Example Code"; %let path = H:\SA

我在网上搜遍了,找不到确切的我需要的东西。在SAS程序结束时,我使用
ods包
方法压缩了最终的数据集(20GB)。我的数据集现在根据需要放在一个压缩文件夹中。现在,我想解压并读入
.sas7bdat
文件,但我不太确定该方法

下面是一个创建永久SAS数据集并将其压缩的示例。我可以查看该zip文件并“查看”所需的数据集,但我不知道如何解压并读入:

** assign your path **;
libname output "H:\SAS Example Code";
%let path = H:\SAS Example Code;

** test data **;
data output.class; set sashelp.class; run;

** zip the permanent SAS dataset **;
ods package(zip) open nopf;
ods package(zip) 
    add file="&path./class.sas7bdat";
ods package(zip) 
    publish archive        
    properties(
        archive_name= "sashelp.class.zip"                  
        archive_path="&path."
        );
ods package(zip) close;

/* BELOW THIS LINE NEEDS WORK -- HOW DO I READ IN THIS DATASET? */

** assign filename and point to zip file **;
filename inzip zip "&path./sashelp.class.zip";

** view the .sas7bdat file within the zip file **;
data contents(keep=memname);
    length memname $200;
    fid=dopen("inzip");
        if fid=0 then stop;
    memcount=dnum(fid);
        do i=1 to memcount;
            memname=dread(fid,i);
        output;
        end;
    rc=dclose(fid);
run;

您基本上需要将文件从ZIP文件中复制出来,然后写入物理文件。您可以使用Chris Hemedinger在其SAS虚拟博客上发布的实用程序

不幸的是,我无法使用
FCOPY()
命令正确复制文件,但他发布的宏仅使用数据步骤来复制文件

所以这里有一个完整的程序来创建一个数据集,压缩它,解压到一个新的名称,并比较这两个版本

* Get path of current WORK directory ;
%let work=%sysfunc(pathname(work));

* Make a new work dataset ;
data work.class; set sashelp.class; run;

** Make the ZIP file **;
ods package(zip) open nopf;
ods package(zip) add file="&work./class.sas7bdat";
ods package(zip) publish archive
    properties(
        archive_name= "sashelp.class.zip"
        archive_path="&work."
        )
;
ods package(zip) close;

* Create filerefs pointing to the source and target ;
filename zipin zip "&work/sashelp.class.zip" member="class.sas7bdat" ;
filename ssdout "&work/class2.sas7bdat";

* Use BINARYFILECOPY macro from Chris ;
%binaryFileCopy
(infile=zipin
,outfile=ssdout
);

* Check if it worked ;
proc compare data=class compare=class2; run;

我不知道有什么本地方法可以做到这一点——我认为您必须通过管道向操作系统发送解压命令。您有这种能力吗?添加compress=YES或使用CPT或XPT文件代替zip文件是一种选择吗?还有更简单的方法来访问文件。@Joe由于服务器权限,我不能使用
X
命令,但我确实使用PuTTY来编写脚本和批处理过程。我认为我的最佳选择是使用SAS压缩,并在需要时使用PuTTY解压缩。