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