When I ran the macro as published, I got an error:

13 %getEngine(SASHELP);
ERROR: Format name I not found or the width and/or decimal specified for the format used are out of range.
SASHELP ENGINE is V9

I changed the following line from:

%let dsid=%sysfunc(open(sashelp.vlibnam(where=(libname="&libref."))),i);

to:

%let dsid=%sysfunc(open(sashelp.vlibnam(where=(libname="&libref.")),i));

Also, the libref passed is case sensitive.