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

Hi, KurtBremser

 

Thanks a lot for your helpful comment. Could you please show me the standard tool to download data from EG(Enterprise Guide) serve?  Thanks a lot.

 

 

Best regards,

Yajun

Kurt_Bremser
Super User

It's the original "ftp" utility, present on all platforms. Just call it with the X statement or call system subroutine. Usage depends on the operating system.

For usage, on UNIX type man ftp, on Windows ftp /?

ChrisHemedinger
Community Manager

If you want to use a SAS program to drive the copy operation, here's a technique you can try.  Two approaches: the DATA step to copy binary files, even from an FTP location, and then also the FCOPY function that might help (SAS 9.4).

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Wang_Yajun
Obsidian | Level 7

Hello,

 

I'm sorry for late reply, as I am asking the SAS Technical support for help. The final solution to download files from EG serve is in the following SAS code. 

options mprint mlogic ;
%macro get_files ;
 
/* use filename FTP to obtain a list of the files in the remote directory */
 filename flist ftp ""
host='172.26.38.38'
user="sasdemo"
pass="Sas123"
ls
cd="\t1" ;
 
data remlist ;
length fname $100 ;
infile flist truncover ;
input fname $100. ;

/* Specifiy a pattern match here to subset the remote files that are to be moved */ 
/*if index(fname,"Test")>0 then output  ; */
run ;
 
/* create a list of macro variables holding the remote file names */ 
proc sql noprint ; select fname into :fname1-:fname32000 from remlist ; %let fcount=%eval(&sqlobs) ; quit;
/* determine count of files */
%put Number of files to be copied:  &fcount ; /*options nonotes nomprint ;*/
 
/* loop through the file list */
%do j=1 %to &fcount ;
 
/* assign a FILENAME FTP for the remote file */ 
filename remfile ftp "&&fname&j"
host="172.26.38.38"
user="sasdemo"
pass="Sas123"
cd="/t1" recfm=f debug;
 
/*FILENAME for the local copy of the file */
filename flocal "C:\temp\download\&&fname&j" recfm=n;
 
%put copying file &j ;
/* data step to copy the remote file */
data _null_ ;
N=1;
infile remfile NBYTE=n;
file flocal;
input ;
put _infile_ @@;
run ;
%end ;
/* of loop */
options notes ;
%mend ;
%get_files ;
Reeza
Super User
Are you planning to use Base SAS to run and develop the code? Base interacts differently and you can see both your remote and local servers and move files between them with a bit more ease.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 3902 views
  • 0 likes
  • 7 in conversation