You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过SAS(SAS Studio/SSOD)用纯代码解压文件并指定目录或提取单个文件

Unzipping Files in SAS Studio (Cloud SSOD Version)

Since you're using the cloud-hosted SAS Studio (SSOD), which runs on a Linux backend, you can build on the pipe method you started with to control extraction paths or pull specific files from your zip archive.

Specify a Custom Output Directory

The unzip command includes a -d flag to define exactly where your extracted files go. First, make sure your target directory exists (you can create it directly from SAS if it doesn't):

/* Create the output directory (and parent folders if needed) */
data _null_;
    infile "mkdir -p /project/output/my_unzipped_files" pipe;
    input;
    put _infile_;
run;

/* Unzip all files to the specified directory */
data _null_;
    infile "unzip /project/input/file.zip -d /project/output/my_unzipped_files" pipe;
    input;
    put _infile_; /* Prints command output/errors for debugging */
run;

The -p flag in mkdir ensures any missing parent directories are created automatically, so you don't have to make them one by one.

Extract a Single File from the Zip

To pull just one specific file from the archive, add the relative path of the file (as it appears inside the zip) to the unzip command:

/* Extract only "sales_data.csv" to the target directory */
data _null_;
    infile "unzip /project/input/file.zip sales_data.csv -d /project/output/my_unzipped_files" pipe;
    input;
    put _infile_;
run;

If the file is nested inside a folder within the zip, include that folder path too (e.g., internal_folder/sales_data.csv).

Debugging Tip

Your original put _infile_ statement is really useful—it prints any output or error messages from the unzip command to the SAS log. This helps you spot issues like missing files, incorrect paths, or permission problems quickly.

内容的提问来源于stack exchange,提问作者TheYeti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:32:41