DATA Step, Macro, Functions and more

Lock available for SAS table

Reply
Super User
Posts: 5,256

Lock available for SAS table

Hi everyone,
Does anybody know a convenient way to find out if I can get an exclusive lock on table, before a batch job is launched? We are using 9.1.3, and both Base and SPDE. Since SPDE apparently doesn't support the LOCK statement, and the OPEN function just open tables in input mode, I don't know what to do.

Thanks,

Linus
Data never sleeps
Super Contributor
Posts: 359

Re: Lock available for SAS table

Here is an example out of a system I am writing. It keeps trying every few seconds until it is free.

%macro update_year( fiscyear);
%if (&syserr = %sysrc(_sok)) %then %do;
%put &sysrc ;
%TRYAGAIN:
lock currbw.br_years;
%put &syslckrc;
%if (&SYSLCKRC ne %sysrc(_sok)) %then %do;
%let rc = %sysfunc(sleep(20000));

%goto TRYAGAIN;
%end;
%else %do;
CALL YOUR EXECUTION HERE;
%end;
lock currbw.br_years clear;
%end;
%else %put Status file not updated for FY &fiscyear because errcode was &syserr ;
%mend;
Super User
Posts: 5,256

Re: Lock available for SAS table

Thanks for your quick response. But SPDE does not support the LOCK statement unfortunately, so I need something else for those libraries.

/Linus
Data never sleeps
Super Contributor
Super Contributor
Posts: 3,174

Re: Lock available for SAS table

You may want to experiment with using LIBNAME / FILENAME and interrogating automatic variables SYSFILRC or SYSLIBRC. Also the parameter WAIT=nn and the SAS OPTIONS FILEMSGS may influence SAS behavior when unsuccessful.

Scott Barry
SBBWorks, Inc.
Super User
Posts: 5,256

Re: Lock available for SAS table

Since our concern is locking on individual objects, I don't think SYSLIBRC will be useful, neither SYSFILRC (which tells whether a physical location/file exists or not). I might be helped with FILEMSGS in some way, but unfortunately we are in UNIX (Solaris), not z/os. I'm not sure how I am intend to use WAIT in this situation.

Regards,
Linus
Data never sleeps
Ask a Question
Discussion stats
  • 4 replies
  • 181 views
  • 0 likes
  • 3 in conversation