title: How do I stop "A lock is not available for <dataset>" errors in SAS?
body: <p>I consistently get "A lock is not available" errors when running SAS programs. It usually happens if I perform operations on the same dataset multiple times in one program. After researching this error, it's my understanding that this means 2 programs are trying to access the same dataset. In other words, it's similar to trying to open a document that is already in  use by someone else or yourself. Here is an example of code that is giving me this error:</p>
  
  <pre><code>data TSTONE.map;
      infile &lt;PATH&gt; delimiter = ',' truncover firstobs=2 dsd TERMSTR=cr LRECL=32760;
  
      format assessment_edition $45.;
      format ...
  
      input
      assessment_edition :$45.
      ...
      ;
  run;
  
  data tstone.map;
      set tstone.map;
      drop DistrictName ...;
  run;
  </code></pre>
  
  <p>I entered "..." in a few places where I have long lists of fields to import or drop. So, first I'm imported a CSV file, and then performing a data step to overwrite the file dropping some fields I don't need. I should note that sometimes when I run programs like this I do not get any lock errors. No other users are accessing these datasets, they are local to my machine. Also, if I highlight and run the 2 data steps sequentially I get no issues.</p>