DATA Step, Macro, Functions and more

Copying External file from Linux SAS Server to Windows directory

Reply
Contributor
Posts: 39

Copying External file from Linux SAS Server to Windows directory

[ Edited ]

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

 

 

 

 

Super User
Posts: 9,594

Re: Copying External file from Linux SAS Server to Windows directory

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 1 reply
  • 101 views
  • 0 likes
  • 2 in conversation