BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Super User Tom
Super User

Use MEMVAR= option, not MEMBER= option.


If that doesn't work then try using DOPEN() DNUM(), DREAD() to get the list of files instead.

filename indir '/home/u.../sasmacs2';
filename out zip '/home/u.../';
data _null_;
  length fname mname $256 ;
  putlog did=;
  do i=1 to dnum(did) ;
     if scan(mname,-1,'.')='sas' then do;
       putlog n= mname= ;
       infile dummy filevar=fname end=eof;
       file out memvar=mname;
       do while (not eof);
         input ;
         put _infile_;
Lapis Lazuli | Level 10

The suggestion Use MEMVAR= option, not MEMBER= option worked just fine. Thank you. MM

Community Manager

Great suggestion, @ChrisNZ. I have pinned this for all users. Thanks for thinking of efficient ways to help our members!

Calcite | Level 5

Just Try providing the full path in to a folder where you can write away!

Quartz | Level 8

To download a directory of SAS files using SAS Studio or SAS on Demand, you can use the following steps:


  1. Open SAS Studio or SAS on Demand in your web browser.
  2. Navigate to the directory that contains the SAS files you want to download.
  3. Select the SAS files you want to download by clicking on the checkbox next to each file.
  4. Click on the "Download" button in the toolbar at the top of the page.
  5. In the "Download" window that appears, select the "Zip" option and click on the "Download" button.
  6. The zip file containing the SAS files will be downloaded to your computer.

Alternatively, you can use the "zip" command in SAS to create a zip file containing the SAS files. To do this, you will need to use the following code:


filename myfiles pipe "zip -r - *.sas";
data null;
infile myfiles recfm=f lrecl=32767;
file myfiles;
put infile;

Replace "myfiles" with the name of the directory that contains the SAS files you want to download. This code will create a zip file called "" that contains all the SAS files in the specified directory. You can then download the zip file to your computer using the "Download" button in SAS Studio or SAS on Demand.

Meteorite | Level 14

Hey All,


The solution is here for *.sas files but sometimes there is a need for zipping a library of SAS datasets. I thought I share my solution for such task.

The BasePlus package contains two macros dedicated to zipping and unzipping a library of datasets.


How to get basePlus package? I will write below, for now assume we already have it installed and loaded into our SAS session.


The zipping macro %zipLibrary() allows to zip all data sets (v7, v8, or v9 with indexes) from SAS library into one zip file:

Lets generate some example data:


options dlcreatedir;
  libname test1 "%workpath()/test1";
  libname test2 "%workpath()/test2";
  libname test3 (test1 test2);
  libname test4 "%workpath()/test4";
options nodlcreatedir;

%put %libPath(test3);
%put %libPath(test4);

  test2.D(where=(Origin NE "Asia") index=(model make io=(invoice origin))) 

data test1.B2 / view=test1.B2;
  set test1.B;


(the %libPath() and %workpath() are utility macros in BasePlus package).


To zip all datasets from test3 library and store the zip file in test4 library just execute:

%zipLibrary(test3, libOut=test4)

as a result you will get file inside the test4 library.


When the zip is ready you can just copy it whenever you want and unzip it by hand (with 7zip for example) or you can use the %unzipLibrary() macro:


%unzipLibrary(%libPath(test4), zip=test3)

As a result you will get all elements from the extracted into the test4 library location.





PS How to get BasePlus?

To work with SAS Packages like BasePlus or others you will need SAS Packages Framework.


Lets assume your SAS session has access to the internet (if not look below).

1) Create a directory where you want to store SPF and packages, for example let it be: "/home/myuserid/SASpackages" under Linux or "C:\Users\myuserid\SASpackages" under Windows.

2) Run the following code only one time to get the SPF:


filename packages "/home/myuserid/SASpackages"; /* setup directory for packages */
filename SPFinit url "";
%include SPFinit; /* enable the framework */

%installPackage(SPFinit) /* install SPF */
%installPackage(BasePlus) /* install BasePlus */

(installation of other packages goes the same way - by installPackage macro).



3) From now on, in this and any new SAS session, to enable SPF and BasePlus just run:

filename packages "/home/myuserid/SASpackages"; /* setup directory for packages */
%include packages(; /* enable the framework */

%loadPackage(BasePlus)    /* load the package content into the SAS session */

4) Enjoy 



No access to the internet on your machine? No problem! Instead step number 2 go here and manually download file. Then go to here and download file. Store them in the directory from step 1 and proceed to step 3.














Polish SAS Users Group: and

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 21 replies
  • 9 in conversation