You can see the source code by running:
package info listutil;
This will tell you the name of the directory where the package is stored and the IML code should be in the sub-directory called 'source'. There is no need to rewrite ListPrint, you are welcome to use my version below.
proc iml;
start L_Print( L, UseNames=0, labl=("--------- List = " + parentname("L") + "---------"),
maxdepth=30);
if type(L) ^= 'L' then return;
/* i indexes items at each depth, n is the list length at each depth. */
i = j(1, maxdepth, 0);
n = j(1, maxdepth, 0);
vnam = 'nam1':('nam'+char(maxdepth));
nstr = j(1, maxdepth, blankstr(40));
d = 1; /* the current depth in the list */
print labl[L=""];
nam1 = ListGetAllNames( L );
n[1] = ListLen( L );
if ncol(nam1)=0 then nam1 = char(1:n[1]);
do until( (d = 0) | (d > maxdepth) );
i[d] = i[d] + 1;
if i[d] <= n[d] then do;
x = ListGetSubItem( L, i[1:d] );
nstr[d] = value(vnam[d])[i[d]];
if nstr[d] = ' ' then nstr[d] = char(i[d]);
if UseNames
then msg = cats(parentname('L'),rowcatc( "['" + nstr[,1:d] + "']"));
else msg = cats(parentname('L'),rowcatc( '[' + char(i[,1:d]) + ']'));
if type(x)='U'
then print ('Undefined') [label=msg];
else if type(x)='C' | type(x)='N' then do;
if ncol(x)=1 then x = t(x);
print x[label=msg];
end; else if type(x)='T' then
call TablePrint(x) label=msg;
else if type(x)='L' then do;
print (cshape('[',1,1,d) + ' LIST ' + cshape(']',1,1,d)) [label=msg];
d = d + 1;
n[d] = ListLen(x);
tn = ListGetAllNames(x);
if ncol(tn)=0 then tn = char(1:n[d]);
call ValSet(vnam[d], tn);
end;
end; else do;
i[d] = 0;
d = d - 1; /* move up the list one level */
end;
end;
finish;
L = [ #'L1' = [ #'L2' = [ #'L3' = [ #'L4' = []]]]] ;
call L_print( L, 1 ) ;
quit;
... View more