BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
MaryA_Marion
Lapis Lazuli | Level 10

I have seen reference to using a zip file to download but not enough detail was included. Do I want to open up the interface or server? It opens to the same thing?

 

Any suggestions or other ideas? Thank you.

MM

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
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.../sasmacs2.zip';
data _null_;
  length fname mname $256 ;
  did=dopen('indir');
  putlog did=;
  do i=1 to dnum(did) ;
     mname=dread(did,i);
     if scan(mname,-1,'.')='sas' then do;
       n+1;
       putlog n= mname= ;
       fname=catx('/',pathname('indir'),mname);
       infile dummy filevar=fname end=eof;
       file out memvar=mname;
       do while (not eof);
         input ;
         put _infile_;
       end;
     end;
  end;
  did=dclose(did);
run;

View solution in original post

21 REPLIES 21
Tom
Super User Tom
Super User

Are you using SAS studio to access SAS or Viya?  Viya does not appear to really have a file system so it will probably be harder to use a non-SAS tool to move files.

 

It is probably easier to upload/download a lot of files using a different user interface than SAS/Studio.

Do you have access to a file system that the server(s) that SAS/Studio is using to run SAS code lives on?  Perhaps you could even connect your personal computer to one of the file systems that the SAS server is using and just use your native file copy methods.  Otherwise you could use an interactive tool (like the FILEZILLA that you appear to be asking about).  Essentially you just need to know what is the path that the files have on the server where SAS is running and move the files from there.

 

If you are forced to use SAS/Studio itself to move the files then it might help to create a ZIP file first and then you only need to copy the one file.   You you might be able to use SAS code to create a ZIP file.  For example if you had a lot of text files on your  SAS server in a particular folder you could make a SAS file that contains those files with a data step like this:

filename in 'path to files';
filename out zip 'filename of new zip file';
data _null_;
  length fname mname $256 ;
  infile in('*') filename=fname ;
  input;
  mname = scan(fname,-1,'/\');

  file out member=mname ;
  put _infile_;
run;
MaryA_Marion
Lapis Lazuli | Level 10
I installed fileZilla but do not know how to complete the connection to sas studio in sas on demand. Please see enclosed file. Thank you. MM
Tom
Super User Tom
Super User

@MaryA_Marion wrote:
I installed fileZilla but do not know how to complete the connection to sas studio in sas on demand. Please see enclosed file. Thank you. MM

I was talking about connecting to some server in your company that you were using to run SAS.

Are you sure that SAS will allow you to connect to the server where SAS runs for SAS Studio on Demand without using SAS/Studio?  I would be surprised if they did that.

yosuryaka1123
Calcite | Level 5

how to download a directory of sas files to pc using sas studio (sas on demand)

ChrisNZ
Tourmaline | Level 20

Filezilla requires an FTP server. Unless one has been installed, you can't use that.

MaryA_Marion
Lapis Lazuli | Level 10
I thought Filezilla was the FTP server. How do I get one? I have no experience with this except I once used CUTE ftp successfully.
ChrisNZ
Tourmaline | Level 20

A browser client needs to connect to a web server, just like an FTP client like Filezilla needs to connect to an FTP server. 

Your IT team typically manages such servers.

MaryA_Marion
Lapis Lazuli | Level 10
Okay let us say that I use cuteFTP as my file server. I will have to log
into it using a password. I don't want to purchase that software without
being reasonably certain that it will work with the SAS server. The big
question I have is how will cuteFTP interface with my online
directories? Will SAS make that possible?
MM
MaryA_Marion
Lapis Lazuli | Level 10

The directory of sas files I want to download is sasmacs2 in my home directory. I am getting error messages when using your code. It asks me for fname and mname. I am not certain what to enter in there?

MM

ChrisNZ
Tourmaline | Level 20

> It asks me for fname and mname.

What does ask mean?

 

fname and mname are populated automatically when you run the program.

 

Show use what you are doing.

MaryA_Marion
Lapis Lazuli | Level 10
filename in '/home/u.../sasmacs2';
filename out zip 'sasmacs2';
data _null_;
  length fname mname $256 ;
  infile in('*') filename=fname ;
  input;
  mname = scan(fname,-1,'/\');
  file out member=mname;
  put _infile_;
run;

Please see log below. I am trying to keep my u number private so you will see ... on the page. I ran the source code while in sasmacs2 directory and while in the home directory with same results.

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 SYMBOLGEN:  Macro variable _SASWSTEMP_ resolves to 
/home/u.../.sasstudio/.images/fefa4007-e77f-4646-84e3-e47c3f4b
23b8
 SYMBOLGEN:  Some characters in the above value which were subject to macro 
quoting have been unquoted for printing.
 SYMBOLGEN:  Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL 
GSFNAME=_GSFNAME;
 68
 69
 70
 71
 72
 73filename in '/home/u.../sasmacs2'; filename out zip 'sasmacs2';data _null_;
 74length fname mname $256 ;
 75infile in('*') filename=fname ;
 76input;
 77mname = scan(fname,-1,'/\');
 78file out member=mname;
 79put _infile_;
 80run;

 NOTE: The infile library IN is:

Directory=/home/u.../sasmacs2, Owner Name=u...,Group Name=oda, Access Permission=drwxr-xr-x,Last Modified=16Aug2021:22:42:00

 NOTE: The infile IN('*') is:

Filename=/home/u.../sasmacs2/DevianceTable.sas, File List=/home/u.../sasmacs2/*,Owner Name=u...,Group Name=oda,Access Permission=-rw-r--r--,Last Modified=25Jul2021:13:06:47,File Size (bytes)=410

 ERROR: Insufficient authorization to access sasmacs2.
 NOTE: A total of 0 records were read from the infile library IN.
 NOTE: 0 records were read from the infile IN('*').
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: DATA statement used (Total process time):
real time0.05 seconds
user cpu time0.01 seconds
system cpu time     0.02 seconds
memory578.59k
OS Memory24224.00k
Timestamp08/17/2021 01:51:55 PM
Step Count39  Switch Count  0
Page Faults0
Page Reclaims90
Page Swaps0
Voluntary Context Switches255
Involuntary Context Switches      0
Block Input Operations8
Block Output Operations8


 81
 82         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 SYMBOLGEN:  Macro variable GRAPHTERM resolves to GOPTIONS NOACCESSIBLE;
 92

 

 

SASKiwi
PROC Star

As I understand it you are using SAS on Demand which operates in a locked down state with limited user permissions. So the errors you are getting are not surprising. You would be best to talk with SAS Tech Support to find out what you can and can't do in SAS on Demand.

ChrisNZ
Tourmaline | Level 20
filename out zip 'sasmacs2';

Try providing the full path, to a folder where you can write. 

MaryA_Marion
Lapis Lazuli | Level 10

Thanks to all of you for your help. I've got the following response from SAS. "Since SAS OnDemand for Academics is a free learning software it does have some limitations as to it's capabilities and unfortunately, SAS OnDemand for Academics is not able to be used with FTP." 

 

I have gotten SAS code to create a zip file. However, it is not opening properly using WinZip on my PC. I'm enclosing the code for you to see as well as the error message on my PC. There are no errors in the log. Zip file was downloaded using the download icon in SAS Studio.

 

SOURCE

filename in '/home/u.../sasmacs2';
filename out zip '/home/u.../sasmacs2.zip';
data _null_;
length fname mname $256 ;
infile in('*') filename=fname ;
input;
mname = scan(fname,-1,'/\');
file out member=mname;
put _infile_;
run;

Log:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; SYMBOLGEN: Macro variable _SASWSTEMP_ resolves to /home/u.../.sasstudio/.images/be90d0a4-57bd-49ef-8e8f-e451f5e9 6f06 SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL
78GSFNAME=_GSFNAME;filename in '/home/u.../sasmacs2'; filename out zip '/home/u.../sasmacs2.zip'; data _null_;length fname mname $256 ;infile in('*') filename=fname ;input;mname = scan(fname,-1,'/\');file out member=mname;put _infile_;run;
NOTE: The infile library IN is:
Directory=/home/u.../sasmacs2, Owner Name=u...,Group Name=oda, Access Permission=drwxr-xr-x,Last Modified=17Aug2021:15:21:32
NOTE: The infile IN('*') is:
Filename=/home/u.../sasmacs2/DevianceTable.sas, File List=/home/u.../sasmacs2/*,Owner Name=u...,Group Name=oda,Access Permission=-rw-r--r--,Last Modified=25Jul2021:13:06:47,File Size (bytes)=410
NOTE: The file OUT is:Filename=/home/u...sasmacs2.zip NOTE: The infile IN('*') is:
Filename= ... 

NOTE: 72 records were read from the infile IN('*').
The minimum record length was 0.
The maximum record length was 83.
NOTE: 8430 records were written to the file OUT.
The minimum record length was 0.
The maximum record length was 32767.
NOTE: DATA statement used (Total process time):
real time 0.17 seconds
user cpu time 0.01 seconds
system cpu time 0.04 seconds
memory 1083.37k
OS Memory 20640.00k
Timestamp 08/19/2021 02:37:22 PM
Step Count 53 Switch Count 0
Page Faults 0
Page Reclaims 249
Page Swaps 0
Voluntary Context Switches 333
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 96
81 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
SYMBOLGEN: Macro variable GRAPHTERM resolves to GOPTIONS NOACCESSIBLE;

MM 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 21 replies
  • 14841 views
  • 17 likes
  • 9 in conversation