BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anand_V
Ammonite | Level 13

Hi All,

 

I have a SAS Dataset in one of my SAS Environment which I move it to another environment using SFTP in SAS Code.

I could do this by logging in to Linux box and then move it manually, but for a project I have to move this multiple times. Could you please assist me with sample code using which I could do the same?

 

Both environments are on LINUX Hosts.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

My preferred method of using the commandline is this:

filename oscmd pipe "sftp sourcefile targetfile 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

filename oscmd clear;

The 2>&1 redirects stderr (standard error output) to stdout, so you get any error messages into your infile. The data _null_ then executes the command and writes output to the SAS log.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Set up public/private key authentication between the users on both hosts. Then you can use sftp from the commandline without the need to log on.

To use this from SAS code, you will need to have xcmd enabled, of course.

Anand_V
Ammonite | Level 13

It's working fine with commandline, Could you please direct me to a sample code that I can use to do it from sas code(EG)?

 

thanks

Kurt_Bremser
Super User

My preferred method of using the commandline is this:

filename oscmd pipe "sftp sourcefile targetfile 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

filename oscmd clear;

The 2>&1 redirects stderr (standard error output) to stdout, so you get any error messages into your infile. The data _null_ then executes the command and writes output to the SAS log.

Anand_V
Ammonite | Level 13
Thanks, this resolved the issue.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 978 views
  • 0 likes
  • 2 in conversation