0

次のコードに問題があり、整理するのに役立つ情報があまり見つかりません。ディレクトリからデータセットにいくつかのファイル名を書き込んでから、それらのファイルの zip ファイルを作成しようとしています。infile ステートメントでデータ ステップに到達するまでは問題なく動作します。次のエラーを受け取りました...

エラー: ファイル名 DIRLIST の論理割り当てがありません。

これが私のコードです...

    %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 in this context is expected a FILENAME reference the kind you have at filename _dir_ "%bquote(&location.)"; It does not understand that you want to use the dataset dirlist.

上記のコード スニペットを次のコードに置き換えます。

data _null_;
    SET dirlist;
于 2014-02-11T16:23:58.050 に答える