BookmarkSubscribeRSS Feed
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.;
  1247 Garcia     04APR54
  1078 Gibson     23APR36
  1005 Knapp      06OCT38
  1024 Mueller    17JUN53

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 ;




Obsidian | Level 7

I would look into the sleep() function. It delays execution by the time specified. 


Here is SAS's documentation on the function:


I quickly wrote up a crude macro that could be used for this. Perhaps there's a more creative method, but this works.



Macro to delay processing: 
Number: Amount of time to wait
Units: Unit of time to wait ("seconds", "minutes", "hours", "days") 

%macro waiting(number, units);
data wait;
  if &units. = "seconds" then unit = 1; *Base unit in sleep function;
  else if &units.="minutes" then unit=60; *60 seconds in a minute;
  else if &units.="hours" then unit=3600; *3,600 seconds in an hours (60 seconds per minute * 60 minutes per hour);
  else if &units.="days" then unit=86400; *86,400 seconds in a day (60 seconds per minute * 60 minutes per hour * 24 hours per day);
  wait_time = sleep(&number., unit);

%waiting(number=10, units="minutes");




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Discussion stats
  • 1 reply
  • 2 in conversation