次のコードに問題があり、整理するのに役立つ情報があまり見つかりません。ディレクトリからデータセットにいくつかのファイル名を書き込んでから、それらのファイルの 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;