Hello. I am trying to create a workflow that reads in a list of files from a system folder, filters the list based on a few other tables, and then provides a list of files that should be moved to another folder. I am having trouble with the last part of this workflow. The dataset that results from the filter contains a single column named FileName which contains files needing to be moved. (filename example: Last, First EmployeeID.TIF) I’ve tried a few solutions like creating a macro scan loop and calling an x command, but each solution I come up with either crashes or fails to move all/any of the files. Any help with this would be great. Here is my latest iteration that tends to just make SAS crash. PROC SQL;
CREATE TABLE WORK.UNIQ_NEW AS
SELECT DISTINCT
CATT('"\\nas\KDrive\EFAX\',t1.FileName,'"') AS FileName
FROM WORK.New t1
ORDER BY t1.FileName;
QUIT;
/* Macro to SCAN through DATALOG */
%MACRO SCANLOOP(SCANFILE,FIELD1);
%LET actioncmd = copy;
%LET destination = "\\nas\\NGH\Forms - New";
%LET separator_s =%str( );
DATA _NULL_;
IF 0 THEN SET &SCANFILE NOBS=X;
CALL SYMPUT('RECCOUNT',X);
STOP;
RUN;
%DO I=1 %TO &RECCOUNT;
DATA _NULL_;
SET &SCANFILE (FIRSTOBS=&I);
CALL SYMPUT('VAR1',&FIELD1);
STOP;
RUN;
%LET command = %sysfunc(catx(&separator_s,&actioncmd,&VAR1,&destination));
x &command;
%END;
%MEND SCANLOOP;
/* Call SCANLOOP */
%SCANLOOP(WORK.UNIQ_NEW,FileName);
RUN;
... View more