BookmarkSubscribeRSS Feed
mslino
Fluorite | Level 6

Hello,

 

I want to upload some PDF files generated in SAS to our FTP server to be available for users to see them through a web application. I have tried to do that using the following code:

 

filename outfile ftp new
     host='10.10.12.100'
     user='user'
     pass='123456'
     rcmd='chmod 0644'
recmf=F; data _null_; set work.tbl_00001 (where=(nm_an eq 'Form')); file outfile filevar=arq; run;

 

The above code is generating an error as follow:

 

ERROR: Insufficient authorization to access /opt/sas94config_anl03/SASApp/15_898699232_217510.pdf

As far as I think, the file might be saved to FTP server, but as the error message state seems the SAS is saving them to the local server rather than in the FTP server.

 

 

What am I missing here? Any idea how to solve this?

 

Regards,

Marcio

 

 

 

 

7 REPLIES 7
Kurt_Bremser
Super User

filevar= is an option that enables a data step to create multiple output TEXT(!) files in one run. The file reference used in the file statement is only a placeholder, a dummy.

I guess that arq contains filenames without an absolute path, so SAS tries to create those files in its current working directory, which is

/opt/sas94config_anl03/SASApp

according to your SAS setup.

Since this CWD is from a UNIX system, you should be able to use scp in an external command to copy your pdf files to the server.

I am astounded that you still use ftp for non-anonymous access. That's a catastrophic security hole, as credentials are sent over the network without encryption. Switch to SSH for non-anonymous data transfer 10 years before yesterday.

mslino
Fluorite | Level 6

Hi Kurt,

 

Thank you for the heads up regarding FTP protocol.

 

Regards,

 

Marcio

Tom
Super User Tom
Super User

What file are you trying to move?  I don't see any files or any attempt to move any files.

You can use the FILE statement in a data step to tell SAS where to send the lines you create with PUT statements in that data step. But your data step doesn't have any PUT statement.

Does your dataset have a list of filenames?

 

Note the error is because the FILEVAR= option is telling the FILE statement to write to the files named in the variable specified so it is trying to open those files for output.

mslino
Fluorite | Level 6

Hi@Tom!

 

I have some PDF files located in my SAS server that I would like to copy or upload to another server. Note that are separated hosts (SAS server is an IBM AIX machine and FTP server is a Virtual SUSE machine).

 

Since the servers are in different IPs, I thought that was possible to transfer the physical PDF file from SAS server to SUSE server and use a web application to show the those PDF in a browser only to our internal network.

 

That dataset (work.tbl_00001) Shown in the code contains the path (arq) where SAS has already save the PDF file, e.g.,/data/gcont/Temp/15_90456789_876543.pdf.  I want to copy each PDF that matches the criteria to our SUSE FTP server.

 

Regards,

 

Marcio

 

Kurt_Bremser
Super User

To use secure ftp, you should first set up passwordless authentication. Create a public/private key pair with ssh-keygen, then copy the public key to the server, and add it there to $HOME/.ssh/authorized_keys. Put the private key in you local .ssh directory. This is important because you have no way to enter a password to the external command.

Then you can start with the following:

%let local_path=local path;
%let remote_path=remote path on the server;
%let sftp_server=hostname or IP of the server;
%let user=username on remote server;

data _null_;
set tbl_00001;
call execute("scp &local_path./" !! trim(arq) !! " &user.@&sftp_server.:&remote_path./" !! trim(arq));
run;

 

mslino
Fluorite | Level 6

Hi @Kurt_Bremser!

 

Your solution is what I need, but I have limited access to our SAS server. Where did I need to put the private key? I use SAS Guide to have access to our SAS server.

 

Regards,

 

Marcio

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2468 views
  • 0 likes
  • 3 in conversation