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 ;
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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.