title: Getting ERROR :Unable to clear or re-assign the library DATA1 because it is still in use in SAS
body: <p>Here is the code I'm running and I'm not sure why I'm getting that ERROR.</p>
  
  <pre><code>options symbolgen mlogic;
  libname lib11 '/home/userid';
  
  %macro SFTPLoop(ds);
     %global numobs;
     %let dsid = %sysfunc(open(&amp;ds));
     %if &amp;dsid %then %do;
        %let NumObs= %sysfunc(AttrN(&amp;dsid,NObs));
        %If &amp;NumObs&gt;0 %THEN %DO;
           %do %while (%sysfunc(fetch(&amp;dsid)) = 0);  
  
           %end;
        %end;
        %else %put ERROR:Data set &amp;dset has 0 rows in it.;
        %let rc = %sysfunc(close(&amp;dsid));
     %end;
     %else %put ERROR:open for data set &amp;dset failed - %sysfunc(sysmsg()).;
  %mend SFTPLoop;
  %SFTPLoop(lib1.data);
  </code></pre>
  
  <p>16         libname lib1 '/home/userid';</p>
  
  <p>ERROR: Unable to clear or re-assign the library LIB1 because it is still in use.
  ERROR: Error in the LIBNAME statement.</p>