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