BookmarkSubscribeRSS Feed
RajasekharReddy
Fluorite | Level 6

Dear all,

 

I want hold Lock for specific dataset in specifed time period like in below program i have written lock statment and lock clear stament

 

want to run lock clear stament after specified time in windows(SAS EG) and unix

 

is any wayt to hold the lock for specified time and when use the same dataset in menioned perios want get error as data set was locked by user

 

data work.test01;
  input @01 employee_id   6.
        @08 last_name     $10.
        @19 birthday      date7.;
  format employee_id   6.
         last_name     $10.
         birthday      date7.;
  datalines;
  1247 Garcia     04APR54
  1078 Gibson     23APR36
  1005 Knapp      06OCT38
  1024 Mueller    17JUN53
;
run;

lock AccesChk.test01 ;

/*wiat for 10 min after lock need to be clear*/
/*and mean while i will use this dataset for other program and i want get error */
/*as data set was locked by user*/

/*is any options for holding some time in windoiws and unix ?*/

lock AccesChk.test01 clear ;

 

2 REPLIES 2
Shmuel
Garnet | Level 18

I'm using SAS UE and tried the LOCK staement.

 

Pay attention: I could rewrite the - so called locked dataset - and sort it without any error:

data test;
    input id;
cards;
111
222
333
; run;

lock work.test;

data test;
   input id;
cards;
555
222
333
; run;

lock work.test;  /* log msg: dataset is already locked by me */

proc sort data=test; by id; run;  /* output order: 222 333 555 */

I cannot check do other users can access the dataset.

The LOCK seems not to be usefull for the locking user.

 

 

Kurt_Bremser
Super User

When you issue a lock() (or whatever the system call is in any given operating system), the system sets the lock for the calling process. As long as you try to modify the file from the same process (read: same workspace server instance), the lock will not be effective; it just blocks other processes from accessing the file.

If you want to see the effect of a lock on another process, just add a sleep call in your code:

lock AccesChk.test01 ;

data _null_;
x1 = sleep(600,1);
run;

lock AccesChk.test01 clear ;

Now you can test if the file is prevented from access in the other session.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 739 views
  • 0 likes
  • 3 in conversation