Date: Mon, 9 Jun 2008 10:25:49 -0400
Reply-To: SUBSCRIBE SAS-L Tom Smith <tomquin99@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SUBSCRIBE SAS-L Tom Smith <tomquin99@GMAIL.COM>
Subject: Re: overwrite a dataset when it is occupied
Here is the code I used>
* session1: occupy the data for 5 minutes, then release.;
libname lib1 '/store/card/d0553/';
data _null_;
do i=1 to 5;
set lib1.mydata; /* when the data is being read, it is not permitted to
be overwritten */
call sleep(60,1);
end;
stop;
run;
/* session2: try overwriting the data, should work after 5 minutes. It
succeeded on PC SAS, but failed (it continued looping till timeout) on
UNIX. -- Can anybody confirm this and find any possible reason for me? */
%let counter=0;
%let repeat=1;
libname final "/store/card/d0553/";
%do %while(&repeat=1 and &counter<10);
/* overwrite the data */
proc datasets library=work nolist;
copy out=final move;
select mydata;
quit;
%if &syserr ^=0 %then %do; /*if overwriting not succeed */
options replace;
%put Warning: Mydata is being locked. wait for 60 sec. counter =
&counter ;
%end;
%else %let repeat=0;
%let counter=%eval(&counter+1);
%let Sleep= %sysfunc(sleep(60,1));
%end;
Thanks a lot.
|