<?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: How to grow a sublist in proc iml? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364998#M3532</link>
    <description>&lt;P&gt;OK, then use ListAddItem in my previous example, which will add it to the end of the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to do this dynamically, you can use the sequence "GetSubItem", "AddItem", "SetSubItem". To make it more efficient, my colleague&amp;nbsp;suggested using the 'm' flag, which does not require making a copy of the memory:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tmp = ListGetSubItem(All, "Residual", 'm');    /* move sublist w/out making a copy */
call ListAddItem(tmp, {10 5 100});             /* add new item */
call ListSetSubItem(All,"Residual", tmp, 'm'); /* move memory back to All; tmp is null */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2017 14:15:20 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-06-07T14:15:20Z</dc:date>
    <item>
      <title>How to grow a sublist in proc iml?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364825#M3529</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How to grow a sublist of the existing List in proc iml?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for eg.&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;Variable = ListCreate();&lt;BR /&gt;Residual = ListCreate();&lt;BR /&gt;Call ListAddItem(Variable,{1 2 34});&lt;BR /&gt;call ListAddItem(Variable,{12 4 2 2});&lt;BR /&gt;Call ListAddItem(Residual,{1 2 34});&lt;BR /&gt;call ListAddItem(Residual,{12 4 2 2});&lt;/P&gt;&lt;P&gt;All = ListCreate({"Variable","Residual"});&lt;BR /&gt;call ListSetItem(All,"Variable",Variable);&lt;BR /&gt;call ListSetItem(All,"Residual",Residual);&lt;BR /&gt;package load ListUtil; /* load ListPrint module */&lt;BR /&gt;run ListPrint(All);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above program, I have a named sublist Variable inside the List All. There is&amp;nbsp;LISTGETSUBITEM function to get the subitem but there is no support to add an item to the sub list or to grow it dynamically. This is useful in cases where all the elements of a sublist are not available right in the beginning and want to maintain a structure like above.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 04:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364825#M3529</guid>
      <dc:creator>karthick_gopal</dc:creator>
      <dc:date>2017-06-07T04:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to grow a sublist in proc iml?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364885#M3530</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call ListInsertItem(Residual,3, 1:3); /* insert */&lt;BR /&gt;call ListSetItem(All,"Residual",Residual); /* replace */&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 10:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364885#M3530</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-06-07T10:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to grow a sublist in proc iml?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364982#M3531</link>
      <description>For this to work, I have to know the elements of Residual before hand. What&lt;BR /&gt;I am looking for is something like this.&lt;BR /&gt;&lt;BR /&gt;List All contains Residual sublist (initial with 2 items in the sublist)&lt;BR /&gt;and let's say I want to add items to Residual sublist in a loop. This is&lt;BR /&gt;what i meant by growing the sublist.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 07 Jun 2017 13:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364982#M3531</guid>
      <dc:creator>karthick_gopal</dc:creator>
      <dc:date>2017-06-07T13:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to grow a sublist in proc iml?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364998#M3532</link>
      <description>&lt;P&gt;OK, then use ListAddItem in my previous example, which will add it to the end of the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to do this dynamically, you can use the sequence "GetSubItem", "AddItem", "SetSubItem". To make it more efficient, my colleague&amp;nbsp;suggested using the 'm' flag, which does not require making a copy of the memory:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tmp = ListGetSubItem(All, "Residual", 'm');    /* move sublist w/out making a copy */
call ListAddItem(tmp, {10 5 100});             /* add new item */
call ListSetSubItem(All,"Residual", tmp, 'm'); /* move memory back to All; tmp is null */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 14:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-grow-a-sublist-in-proc-iml/m-p/364998#M3532</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-06-07T14:15:20Z</dc:date>
    </item>
  </channel>
</rss>

