Hi All,
I'd like to ask your help regarding on converting the ftp code in a .sh file below to a code that can run in SAS BASE?
#!/bin/bash
WINDOWS_SERVER=sasftp001
USER=sasdemo
PASSWORD=abc123
ftp -in <<EOF
open $WINDOWS_SERVER
user $USER $PASSWORD
ascii
lcd /sas/sasdata/data/myfolder
put test.txt
cd /WindowsFolder/App/Data
close
EOF
The code above is working fine. Can everybody help me translate this one to a sas code? I created an ftp code but its not working so i tried creating the above script. Below is my SAS code :
filename src ftp 'linux path' host='abc.com.' binary dir
user = 'sasdemo' pass= "abc123";
filename tgt ftp 'windows path' host='sasftp001' binary dir user='sasdemo' pass= "abc123;
data _null_;
infile src(test.txt) truncover;
input;
file target(test.text);
put _infile_;
run;
Thanks,
Albert0
Is SAS running on one of the involved servers? This would allow a simpler filename statement for either source or target.
When reading/writing text files, avoid the binary option, and use the complete absolute pathnames in the filename statements:
filename src ftp
"/linux path/test.txt"
host='abc.com'
user = 'sasdemo'
pass= "abc123"
;
filename tgt ftp
"windows path\test.txt"
host='sasftp001'
user='sasdemo'
pass= "abc123"
;
data _null_;
infile src;
file tgt;
input;
put _infile_;
run;
Post your log for steps that do not work.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.