<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770550#M5663</link>
    <description>&lt;P&gt;In SAS 9, the STRUCT and LISTPRINT functions are implemented as SAS/IML modules that are defined in the ListUtil package. They are only implemented to support up to three levels of nesting.&amp;nbsp; You can run STRUCT on sublists to see additional structures, such as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;L111 = L$1$1$1;&lt;/P&gt;
&lt;P&gt;RUN STRUCT(L111);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Viya, the iml action and the IML procedure support the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_012/casactiml/casactiml_langref_sect128.htm" target="_self"&gt;STRUCT subroutine&lt;/A&gt; and the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_012/casactiml/casactiml_langref_sect125.htm" target="_self"&gt;LISTPRINT subroutine&lt;/A&gt; as built-in functions. You do not need to load a package. In Viya, these functions display the complete structure of lists to arbitrary depths of nesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Sep 2021 23:45:36 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2021-09-26T23:45:36Z</dc:date>
    <item>
      <title>Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770542#M5662</link>
      <description>&lt;P&gt;Here is an example of a list that has four levels of nesting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ; package load listutil ;
L = [ #'L1' = [ #'L2' = [ #'L3' = [ #'L4' = []]]]] ;
call struct( L ) ;
call listprint( L ) ;
quit ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I look at the results, I see&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rbettinger_0-1632689287094.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64085i0A99E6FBD9AD1547/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rbettinger_0-1632689287094.png" alt="rbettinger_0-1632689287094.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and no indication of sublist L4. Sublist L3 is mentioned in the Listprint() call and apocryphically in the Struct() call by the fact that name L2 is a pointer to a list, but what happened to sublist L4?&lt;/P&gt;
&lt;P&gt;How can I see &lt;EM&gt;all&lt;/EM&gt; of the objects of a list and the &lt;EM&gt;complete&lt;/EM&gt; structure of a list?&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 20:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770542#M5662</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2021-09-26T20:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770550#M5663</link>
      <description>&lt;P&gt;In SAS 9, the STRUCT and LISTPRINT functions are implemented as SAS/IML modules that are defined in the ListUtil package. They are only implemented to support up to three levels of nesting.&amp;nbsp; You can run STRUCT on sublists to see additional structures, such as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;L111 = L$1$1$1;&lt;/P&gt;
&lt;P&gt;RUN STRUCT(L111);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Viya, the iml action and the IML procedure support the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_012/casactiml/casactiml_langref_sect128.htm" target="_self"&gt;STRUCT subroutine&lt;/A&gt; and the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_012/casactiml/casactiml_langref_sect125.htm" target="_self"&gt;LISTPRINT subroutine&lt;/A&gt; as built-in functions. You do not need to load a package. In Viya, these functions display the complete structure of lists to arbitrary depths of nesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 23:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770550#M5663</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-09-26T23:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770551#M5664</link>
      <description>Is the source code for ListPrint() and struct() available so that I might&lt;BR /&gt;customize the modules to expand their capabilities? It's hard to constantly&lt;BR /&gt;specify subitems of a list to display the entire list.&lt;BR /&gt;</description>
      <pubDate>Sun, 26 Sep 2021 23:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770551#M5664</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2021-09-26T23:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770582#M5665</link>
      <description>&lt;P&gt;You can see the source code by running:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;package info listutil;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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'.&amp;nbsp; There is no need to rewrite ListPrint, you are welcome to use my version below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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 &amp;gt; maxdepth) );
	 i[d] = i[d] + 1;
     if i[d] &amp;lt;= 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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Sep 2021 08:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770582#M5665</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2021-09-27T08:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770643#M5666</link>
      <description>Ian, thank you very much for sharing your code with the SAS/IML community.&lt;BR /&gt;Your L_Print module is a model of clarity in form and function and I will benefit from learning how lists are structured and manipulated by studying your module.</description>
      <pubDate>Mon, 27 Sep 2021 14:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770643#M5666</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2021-09-27T14:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't Struct(L) and ListPrint(L) display all of the items of a list?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770826#M5667</link>
      <description>&lt;P&gt;Thanks for your kind words.&amp;nbsp; I should make it clear that I did exactly what you proposed to do above, and started from the code in the package.&amp;nbsp; So I would like to acknowledge Rick for writing the original ListPrint - I definitely learned a few things from his code!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 08:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Why-don-t-Struct-L-and-ListPrint-L-display-all-of-the-items-of-a/m-p/770826#M5667</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2021-09-28T08:52:21Z</dc:date>
    </item>
  </channel>
</rss>

