我在文件服务器上有一个sas-db文件,并且想检查它是否由另一台PC打开。SAS检查文件服务器上的文件是否被其他PC打开
我试了几次尝试使用此源http://www.wuss.org/proceedings11/Papers_Galligan_O_74889.pdfhttp://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p0a6vn2td7bjr2n1viy8y4lgvq61.htm没有成功。 日志中的数字(fid)永远不会变为0,而不管该文件是否在另一台PC上打开。
%MACRO Try;
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf,\\inti\[...]\p3001_overviewsampling.sas7bdat));
%let fid=%sysfunc(fopen(&filrf));
%PUT RC is: &RC // fid is &fid ;
%MEND;
%Try;
LOG: RC is: 20036 // fid is 30
任何想法? 谢谢,数据的回答空 ----------------
感谢您的休息后Lubenja
------编辑。但是,如果我运行两次宏,则不再有效。即使从同一台PC运行,文件也会被锁定。现在我不能从任何一台PC上删除文件。
17 %LET Path =\\hugo\Temp;
18 LIBNAME test "&Path";
NOTE: Libref TEST was successfully assigned as follows:
Engine: V9
Physical Name: \\hugo\Temp
19
20
21 data test.class2;
22 set sashelp.class;
23 run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set TEST.CLASS2 has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
24
25 %MACRO Try(data=,library=);
26 %let filrf=myfile;
27 %let rc=%sysfunc(filename(filrf,%sysfunc(pathname(&library))/&data..sas7bdat));
28 %let fid=%sysfunc(fopen(&filrf,O));
29 %PUT RC is: &RC // fid is &fid ;
30 %if &fid %then %let rc=%sysfunc(fclose(&fid));
31 %MEND;
32 %Try(data=class2,library=test);
RC is: 0 // fid is 1
33 %Try(data=class2,library=test);
RC is: 0 // fid is 0
34 data test.class2;
35 set sashelp.class;
36 run;
ERROR: An I/O error has occurred on file TEST.CLASS2.DATA.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
如果你是想为了写它看看这个答案HTTP来锁定一个SAS数据集://计算器。 com/a/17871132/214994。 –