0

I'm having issues with the foloowing code and I can't seem to find much information to help me sort it out. I'm trying to write some filenames from a directory to a datset, then create a zip file of those files. It works fine until I reach the data step with the infile statement. I received the following error...

ERROR: No logical assign for filename DIRLIST.

Here is my code...

    %macro get_filenames(location);
    filename _dir_ "%bquote(&location.)";
    data filenames(keep=fname);
  handle=dopen( '_dir_' );
  if handle > 0 then do;
    count=dnum(handle);
    do i=1 to count;
      fname=dread(handle,i);
      output filenames;
    end;
  end;
  rc=dclose(handle);

run;
filename _dir_ clear;
%mend;

%get_filenames(c:\temp\);           

data dirlist;
 set filenames;
 where fname like 'scra%.txt';
run;

ods package(testfile) open nopf;

data _null_;
    infile dirlist pad lrecl=80;
    input @1 filename $80.;
    call execute
        (catx
            (' ',
            'ods package(testfile)',
            'add file=',
            quote('c:\temp\' || trim(filename)),
            ';'
            )
        );
run;

ods package(testfile) publish archive
properties(archive_name='testfile.zip'
archive_path='c:\temp\' );


ods package(testfile) close;
4

1 回答 1

0

我认为 SAS 在您的代码中抱怨以下内容:

data _null_;
    infile dirlist pad lrecl=80;

在这种情况下, Infile期望 FILENAME 引用您所拥有的那种filename _dir_ "%bquote(&location.)"; 它不明白您要使用数据集 dirlist

将上面的代码片段替换为以下内容:

data _null_;
    SET dirlist;
于 2014-02-11T16:23:58.050 回答