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 ;

 

 

 

1 REPLY 1
Rwon
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:

http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#p0a6vn2td7b...

 

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);
  run;
%mend;

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

 

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!

Discussion stats
  • 1 reply
  • 727 views
  • 0 likes
  • 2 in conversation