I figured it out. Using the FILENAME DIR ls statement, I retrieve the filenames I'm looking for in a data step with a condition. As it's pulling these file names, I call a macro that takes the current filename variable and runs it through an INFILE, after which the data is appended to a table I have created. Pasting the code below for future reference for anyone else hoping to import multiple FTP files in a simple fashion: /* CREATE FILE IMPORT MACRO */ OPTIONS MPRINT; %MACRO importFTPfiles (currentfile=); FILENAME ftpfiles FTP "¤tfile" lrecl = 300 CD='/directory' HOST='host' USER='user' PASS='pass!' ; DATA currentfile; LENGTH PhoneNum 8 cust_acct_num 8; FORMAT PhoneNum BEST10. cust_acct_num BEST10.; INFORMAT PhoneNum BEST10. cust_acct_num BEST10.; INFILE ftpfiles ENCODING="wlatin1" TERMSTR=LF DLM='|' MISSOVER DSD FIRSTOBS=2; INPUT PhoneNum : ?? BEST10. dtv_acct_num : ?? BEST10.; RUN; PROC APPEND base=ftpimports data=currentfile; RUN; %MEND importFTPfiles; /* CREATE TABLE TO HOUSE THE LATEST INCOMING RECORDS */ DATA tcs.ftpimports; LENGTH PhoneNum 8 cust_acct_num 8; FORMAT PhoneNum BEST10. cust_acct_num BEST10.; INFORMAT PhoneNum BEST10. cust_acct_num BEST10.; CALL MISSING(of _all_); STOP; run; /* GET THE FTP DIRECTORY LISTING */ filename dirlist ftp '' ls CD='/directory' HOST='host' USER='username' PASS='passwd'; /* Pull listing of files, filtered and run through macro */ data dirlist; infile dirlist length=reclen; input fname $varying200. reclen; if upcase(fname)=: 'ACCOUNT201111'; /* execute macro while sending each file name sequentially to the macro */ call execute('%importFTPfiles(currentfile='||fname||')'); run;
... View more