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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 19 replies
  • 2809 views
  • 0 likes
  • 7 in conversation