Saturday, March 31, 2012

SAS to FTP files. General code.


This code is basically to use FTP from SAS, i hope you guys can use it at many places.

FTP data from sas to mainframe or any place :
(i use the code to ftp to mainframe , but it works for any other place too)


%let userId=;
%let pwdId=;

%let MVSZoS = MVSIBM.test.a; /* or give a ip address as /*

%let MVSZoS = 10.255.255.1; /* if u have the ip use this */

%let tempfile=c:\test_Ftp.prm; /*this is the input file you want to ftp (on from server)*/

%let out=myid.test.recieve.ftp; /* this is the file name to recieve ftp (on to server)*/

%let scr=c:\ftpparmameters.scr; /* this is a script file, just create a blank empty file on your
server ( from serve) */

filename f "&scr";


data _null_;
file f;
put "open &MVSZoS";
put "&userId";
put "&pwdId";
put 'cd ..';
put "send &tempfile" " &out";
put 'quit';
run;

%macro makework;
data _null_;
infile makework;
input;
put _infile_;
call symput('timestmp',datetime() );
run;
%mend;

%makework;

filename makework pipe "ftp -s:&scr";


This is more or less a general code , just change the parameters in let statements and you make it yours !

Like to hear your comments.


Thanks,
KB

2 comments: