外部ファイルについての情報アイテムの名前を返します。
カテゴリ: | 外部ファイル |
%let filrf=myfile; %let rc=%sysfunc(filename(filrf, physical-filename)); %let fid=%sysfunc(fopen(&filrf)); %let infonum=%sysfunc(foptnum(&fid)); %do j=1 %to &infonum; %let name=%sysfunc(foptname(&fid, &j)); %let value=%sysfunc(finfo(&fid, &name)); %put File attribute &name equals &value; %end; %let rc=%sysfunc(fclose(&fid)); %let rc=%sysfunc(filename(filrf));
data fileatt; length name $ 20 value $ 40; drop rc fid j infonum; rc=filename("myfile", "physical-filename"); fid=fopen("myfile"); infonum=foptnum(fid); do j=1 to infonum; name=foptname(fid, j); value=finfo(fid, name); put 'File attribute ' name 'has a value of ' value; output; end; rc=filename("myfile"); run;
data fileatt;
filename mypipe pipe 'dir';
fid=fopen("mypipe","s");
/* fid should be non—zero. 0 indicates failure */
put "File id is: " fid=;
numopts=foptnum(fid);
put "Number of information items should be 4; " numopts=;
do i=1 to numopts;
optname=foptname(fid,i);
put i= optname=;
optval=finfo(fid,optname);
put optval=;
end;
rc=fclose(fid);
run;
NOTE:PROCEDURE PRINTTO used (Total process time): real time 0.03 seconds cpu time 0.01 seconds 6 data fileatt; 7 filename mypipe pipe 'dir'; 8 fid=fopen("mypipe","s"); 9 /* fid should be non-zero.0 indicates failure */ 10 put "File id is:" fid=; 11 numopts=foptnum(fid); 12 put "Number of information items should be 4; " numopts=; 13 do i=1 to numopts; 14 optname=foptname(fid,i); 15 put i= optname=; 16 optval=finfo(fid,optname); 17 put optval=; 18 end; 19 20 rc=fclose(fid); 21 run; File id is: fid=1 Number of information items should be 4; numopts=4 i=1 optname=Unnamed Pipe Access Device optval= i=2 optname=PROCESS optval=dir i=3 optname=RECFM optval=V i=4 optname=LRECL optval=32767 NOTE:The data set WORK.FILEATT has 1 observations and 6 variables.NOTE:DATA statement used (Total process time): real time 9.64 seconds cpu time 1.16 seconds 22 proc printto; run;
data fileatt; length name $ 20 value $ 40; drop fid j infonum; filename mypipe pipe 'UNIX-command'; fid=fopen("mypipe", "s"); infonum=foptnum(fid); do j=1 to infonum; name=foptname(fid, j); value=finfo(fid, name); put 'File attribute' name 'has a value of ' value; output; end; run;
File attribute Pipe Command has a value of UNIX-command