分类: 数据库开发技术
2009-07-16 11:15:35
%marco getfile2();
filename indir ftp '/stage/20090101' DIR
host="192.168.24.119"
user="admin" pass='admin' prompt rcmd='binary' recfm=s debug;
filename aa "c:\" recfm=n;
data _null_;
infile indir(cdr20090101.gz) NBYTE=n;
input;
file aa(cdr20090101.gz);
put _infile_ @@;
run;
%mend;
/*从FTP下载文件macro2*/
%macro getfile2(lcd,cd,user,pwd,host);
filename dir ftp '' ls user="&user." pass ="&pwd."
host="&host." cd = "&cd." prompt;
data _null_;
length fname $50.;
infile dir;
input fname;
put fname = ;
call symput(compress("fname"||_N_),compress(fname));
call symput("count",_N_);
run;
%do i = 1 %to &count.;
filename remote ftp "&cd." DIR
host="&host."
user="&user." pass="&pwd." prompt rcmd="binary" recfm=s debug;
filename local "&lcd." recfm=n;
data _null_;
infile remote("&&fname&i.") NBYTE=n;
input;
file local("&&fname&i.");
put _infile_ @@;
run;
%end;
%mend;
%getfile2(D:\wep\cai\raw,/stage/20090102,admin,admin,192.168.24.119);
filename remote ftp "/stage/result" DIR
host="192.168.24.119"
user="admin" pass="admin" prompt rcmd="binary" recfm=s debug;
filename local "c:\" recfm=f;
data _null_;
infile local(cdr20090101.gz);
input;
file remote(cdr20090101.gz) ;
put _infile_ @@;
run;