<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unlocking a locked a Locked dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351345#M258602</link>
    <description>You can unlock a locked sas dataset in Unix by either deleting the dataset&lt;BR /&gt;files at operating system level, or by renaming the dataset files at OS&lt;BR /&gt;level and then copying them back to their original names then delete the&lt;BR /&gt;renamed versions.&lt;BR /&gt;&lt;BR /&gt;Be sure not to OS delete or move/copy if a . lck file exists as this means&lt;BR /&gt;the dataset is locked for update.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Paul&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
    <pubDate>Wed, 19 Apr 2017 15:38:01 GMT</pubDate>
    <dc:creator>Paul_Dutton</dc:creator>
    <dc:date>2017-04-19T15:38:01Z</dc:date>
    <item>
      <title>Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/107090#M258598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am appending&amp;nbsp; data to a dataset in a Unix environment. However, someone opened the table and forget to close&amp;nbsp; it there by locking the table,. Any idea how to unlock the dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 01:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/107090#M258598</guid>
      <dc:creator>sasthebest</dc:creator>
      <dc:date>2013-10-09T01:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/107091#M258599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only way to unlock the table is to kill the (SAS-) process locking the table - or to ask the user locking the table to close it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is unfortunately a common problem with EG users. Newer versions of EG have under "Tools/options/Data/Performance" a setting "Close data grid after period of inactivity". I believe the default is set to 30 minutes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to kill the process then Google with keywords like "unix process locking file" and you will find syntax to determine which process locks the table. You then still need the privileges to kill the process. I believe the command is "kill -9 &amp;lt;pid&amp;gt;".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 02:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/107091#M258599</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-09T02:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/268762#M258600</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a solution for this.&lt;/P&gt;&lt;P&gt;1) check for the .lck file for the sas dataset, if it exists then it is currently being updated so do not try and unlock it.&lt;/P&gt;&lt;P&gt;2) if no .lck file exists, you can OS move(rename) the dataset file(s) including indexes and then copy them back to their original names, once the copy is complete you can remove the renamed copies.&amp;nbsp;&amp;nbsp; This method is qiute IO intensive but always releases the lock and retains the data.&amp;nbsp; If the target table is to be replaced, then you can simply delete the OS dataset files to break the lock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written macros to try locking the table, if that fails then it&amp;nbsp;either OS deletes or OS Copies (based on selected option) to break the lock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please conatct me if you would like my macro..&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 09:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/268762#M258600</guid>
      <dc:creator>Paul_Dutton</dc:creator>
      <dc:date>2016-05-06T09:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351259#M258601</link>
      <description>&lt;P&gt;Can you share your macro with me ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 12:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351259#M258601</guid>
      <dc:creator>busrafenerci</dc:creator>
      <dc:date>2017-04-19T12:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351345#M258602</link>
      <description>You can unlock a locked sas dataset in Unix by either deleting the dataset&lt;BR /&gt;files at operating system level, or by renaming the dataset files at OS&lt;BR /&gt;level and then copying them back to their original names then delete the&lt;BR /&gt;renamed versions.&lt;BR /&gt;&lt;BR /&gt;Be sure not to OS delete or move/copy if a . lck file exists as this means&lt;BR /&gt;the dataset is locked for update.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Paul&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 19 Apr 2017 15:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351345#M258602</guid>
      <dc:creator>Paul_Dutton</dc:creator>
      <dc:date>2017-04-19T15:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351400#M258603</link>
      <description>&lt;P&gt;I'm just typing you a macro into here, no testing has been done on it.&lt;/P&gt;&lt;P&gt;You will need XCMD enabled...&lt;/P&gt;&lt;P&gt;%macro unlock(lib=,dataset=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* you may want to check for a lock first by unlocking the dataset and trapping the error, then proceed with the following */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path=%sysfunc(pathname(&amp;amp;lib.));&lt;/P&gt;&lt;P&gt;%let dset=%lowcase(&amp;amp;dataset.).sas7bdat;&lt;/P&gt;&lt;P&gt;%let index=%lowcase(&amp;amp;dataset.).sas7bndx;&lt;/P&gt;&lt;P&gt;%let lock=%lowcase(&amp;amp;dataset.).sas7bdat.lck;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if not %sysfunc(fexist(&amp;amp;path./&amp;amp;lock.)) %then %do;&lt;/P&gt;&lt;P&gt;/* lock file does not exist - proceed */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %sysfunc(fexist(&amp;amp;path./&amp;amp;dset.)) %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* dataset file exists - OS unlock */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; filename cmd pipe "mv -v ""&amp;amp;path./&amp;amp;dset."" ""&lt;SPAN&gt;&amp;amp;path./&amp;amp;dset._mv""; cp -v ""&amp;amp;path./&amp;amp;dset._mv"" -v ""&amp;amp;path./&amp;amp;dset.""; rm&amp;nbsp;""&amp;amp;path./&amp;amp;dset._mv""";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; infile cmd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; %if %sysfunc(fexist(&amp;amp;path./&amp;amp;index.)) %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* index file exists - OS unlock */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; filename cmd pipe "mv -v ""&amp;amp;path./&amp;amp;index."" ""&lt;SPAN&gt;&amp;amp;path./&amp;amp;index._mv""; cp -v ""&amp;amp;path./&amp;amp;index._mv"" -v ""&amp;amp;path./&amp;amp;index.""; rm&amp;nbsp;""&amp;amp;path./&amp;amp;index._mv""";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; infile cmd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %put %upcase(error): &amp;amp;lib..&amp;amp;dataset. Lock file exists - dataset being updated aborting unlock procedure.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Usage&lt;/P&gt;&lt;P&gt;%unlock(lib=LIBREF,dataset=SOME_DATASET);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This only works on SAS libraries with a single file path.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 17:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/351400#M258603</guid>
      <dc:creator>Paul_Dutton</dc:creator>
      <dc:date>2017-04-19T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unlocking a locked a Locked dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/820171#M323704</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84435"&gt;@Paul_Dutton&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thank you for your code. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a process that copies a dataset ; if the dataset already exists and I can’t acquire a lock, I just simply do a FDELETE &amp;nbsp;(because it is ok in our case) which allows for me to continue my copy because we use LINUX. &amp;nbsp;Therefore i am freeing the dataset.&lt;/P&gt;
&lt;P&gt;But unfortunately with Windows, if a dataset is opened or locked we can’t use any of the cmd listed in the pipe line that you provided.&lt;/P&gt;
&lt;P&gt;I was able to use your code by using the « DOS » commands with the Pipe if the dataset isn’t locked ….I learned something with pipes. &amp;nbsp;Thank you.&lt;BR /&gt;With Linux, if I have a locked dataset, I can easily do a fdelete, and then I can copy the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 00:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unlocking-a-locked-a-Locked-dataset/m-p/820171#M323704</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2022-06-24T00:11:04Z</dc:date>
    </item>
  </channel>
</rss>

