BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AnandVyas
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.

AnandVyas
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.

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1272 views
  • 0 likes
  • 2 in conversation