Write and run SAS programs in your web browser

How to use PROC UPLOAD/DOWNLOAD in SAS Studio

Reply
Occasional Contributor
Posts: 7

How to use PROC UPLOAD/DOWNLOAD in SAS Studio

Hello,

 

I'm trying to use proc upload and download in sas studio but I'm having trouble.

 

I tried :

 

 

 
proc download infile="server/path/my_pgm.sas"
outfile="D:\local_path\test.sas";
run;

 

and 

 

proc upload infile="D:\local_path\test.sas"
outfile="server/path/my_pgm.sas";
run; 

 

But nothing happen and I have the following warning :

 

WARNING: PROC DOWNLOAD must be invoked with the RSUBMIT command.

 

If I use rsubmit/endrsubmit (which is weird as I'm already connected to my server).

 

i have the following error :

ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id.
NOTE: Subsequent lines will be ignored until ENDRSUBMIT.
ERROR: Remote submit to UNKNOWN canceled.

 

 

The previous code is working in SAS local with rsubmit/endrsubmit.

 

I don't understand why this is not working in sas studio without the rsubmit/endrsubmit;

 

Does anyone have an answer ?

 

 

Thank you !!

 

 

Super User
Super User
Posts: 6,696

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

For PROC UPLOAD or DOWNLOAD to work you need to have two SAS sessions connected by a SAS connect session. When you run something in SAS/Studio you generally just have the one SAS session running. SAS/Studio itself is not running SAS. It is just a web interface.  You can use the SAS/Studio interface to manually copy files, but you cannot get the SAS program to do that for you.

 

There are other ways depending on your environment.

 

If you are using SAS University Edition then your SAS session can only write to folders that are mapped to your virtural machine. And the SAS code will need to use the unix path for that folder and not the path that you would use from your real PC environment.  No need to UPLOAD/DOWNLOAD just reference the file directly using the proper path.

 

Otherwise if you are running SAS on a Unix machine then perhaps you can used network drives that can be seen from both Unix and Windows machines. So you might have a network share that from a PC looks like \\servername\sharename\sasfiles and from UNIX it is mounted at /servername/sharename/sasfiles.  Just use the right path on the right system.

 

Or you perhaps it would be better to setup an FTP server on your PC and allow the SAS process to use FTP to move files to and from your PC.  

Occasional Contributor
Posts: 7

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

Hi Tom,

 

Thank you for your reply.

 

I don't have SAS University so I usually use FileZilla to transfer my files manually but I wanted to do it in an automatic way in codes.

 

Seems it's not possible Smiley Sad

 

thank you again !!

 

Super User
Posts: 7,094

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

One way could be this:

- install (or have installed) a (s)ftp server on your PC (ie https://filezilla-project.org/download.php?show_all=1&type=server)

- use the SAS server's sftp client to connect to it; set up public/private key authentication between your SAS server and your PC

- once that is running, you can use filename sftp from within SAS; or use the sftp client with X or filename pipe.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 6,696

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

I believe that you can use FileZilla to setup an FTP server on your PC.  Then your SAS code can simply use the FTP filename engine.

 

filename outfile "D:\local_path\test.sas"
    host='winnt.pc'
    user='bbailey'
    password='xxxx' 
;

data _null_;
  infile "/server/path/my_pgm.sas";
  file outfile;
  input;
  put _infile_;
run;
Occasional Contributor
Posts: 7

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

I think i'm gonna try !

Thankss
Super User
Posts: 5,317

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

To be clear, before you had a local SAS session and communicated to a remote SAS server using SAS/CONNECT.

And now in SAS Studio, is that client started from the SAS Server or from the local PC SAS installation?

If you run SAS Studio from the server, you can't use SAS/CONNECT to move data from your local PC to the server, you need other means (ftp, shared file system/mapped network drive).

Data never sleeps
Occasional Contributor
Posts: 7

Re: How to use PROC UPLOAD/DOWNLOAD in SAS Studio

Thanx Lush.

I think that the client is started from the SAS server that's why it's not working...
Ask a Question
Discussion stats
  • 7 replies
  • 122 views
  • 0 likes
  • 4 in conversation