<?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: ListGetItem Command-Type of matrix error in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615293#M4954</link>
    <description>&lt;P&gt;The ISEMPTY function tests whether a matrix has zero rows and zero columns. The error message says that subs[j] is not a matrix, which is true because the sublist operator ([ ]) always returns a list.&amp;nbsp; I don't know what you are trying to do, but here are two options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You can use the LISTLEN function to test whether a list has zero elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;IF LISTLEN(subs[j])=0 THEN...&lt;/P&gt;
&lt;P&gt;2. You can extract the j_th element from a list by using the list item operator ($):&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;IF IsEmpty(subs$j) THEN...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jan 2020 12:02:56 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-01-06T12:02:56Z</dc:date>
    <item>
      <title>ListGetItem Command-Type of matrix error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615229#M4953</link>
      <description>&lt;P&gt;When I try to use the Listgetitem command I get the following error:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Note:(subs is the list name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8807 do j=1 to numSubs;&lt;BR /&gt;8808&lt;BR /&gt;8809 if IsEmpty(subs[j]) then do;&lt;BR /&gt;8809! ps0vector=1;&lt;BR /&gt;8809! end;&lt;BR /&gt;8810 else do;&lt;BR /&gt;8811 d=ListGetItem(subs, j);&lt;BR /&gt;8812 print d;&lt;BR /&gt;8813 end;&lt;BR /&gt;8814 end;&lt;BR /&gt;8815 end;&lt;BR /&gt;8816 end;&lt;BR /&gt;NOTE: Module ISEMPTY loaded from the storage SASHELP.IMLMLIB.&lt;BR /&gt;ERROR: &lt;STRONG&gt;Matrix d must be numeric or character.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;statement : PRINT at line 8812 column 1&lt;BR /&gt;8817 run;&lt;BR /&gt;NOTE: Module MAIN is undefined in IML; cannot be RUN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to solve this?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2020 23:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615229#M4953</guid>
      <dc:creator>Sanscrit_2prov</dc:creator>
      <dc:date>2020-01-05T23:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: ListGetItem Command-Type of matrix error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615293#M4954</link>
      <description>&lt;P&gt;The ISEMPTY function tests whether a matrix has zero rows and zero columns. The error message says that subs[j] is not a matrix, which is true because the sublist operator ([ ]) always returns a list.&amp;nbsp; I don't know what you are trying to do, but here are two options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You can use the LISTLEN function to test whether a list has zero elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;IF LISTLEN(subs[j])=0 THEN...&lt;/P&gt;
&lt;P&gt;2. You can extract the j_th element from a list by using the list item operator ($):&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;IF IsEmpty(subs$j) THEN...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 12:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615293#M4954</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-06T12:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: ListGetItem Command-Type of matrix error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615395#M4955</link>
      <description>&lt;P&gt;Hi: The error I was referring to was the one about matrix d being numeric or character.&lt;/P&gt;&lt;P&gt;Here's some more code to describe the problem better and the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subs=listcreate(numNzs);&lt;BR /&gt;&lt;BR /&gt;3405&amp;nbsp; do j=1 to numSubs;&lt;BR /&gt;3406&lt;BR /&gt;3407&amp;nbsp; if listlen(subs[j])=0 then do;&lt;BR /&gt;3407&amp;nbsp; ps0vector=1;&lt;BR /&gt;3407 end;&lt;BR /&gt;3408 else do;&lt;BR /&gt;3409 d=ListGetItem(subs,j);&lt;BR /&gt;3410 print d;&lt;BR /&gt;3412 end;&lt;BR /&gt;3413 end;&lt;BR /&gt;&lt;STRONG&gt;ERROR: Matrix d must be numeric or character.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 17:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615395#M4955</guid>
      <dc:creator>Sanscrit_2prov</dc:creator>
      <dc:date>2020-01-06T17:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: ListGetItem Command-Type of matrix error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615415#M4956</link>
      <description>&lt;P&gt;Ahh, sorry. The error is that the PRINT statement in PROC IML (15.1) prints valid matrices. Apparently D is not a matrix for some value of j.&amp;nbsp; &lt;A href="https://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_lists_details09.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;You can use the LISTPRINT modules (or the STRUCT module) to print lists.&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the list contains some elements that are matrices and others that are lists, you can use the TYPE function to determine how to print the item:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
package load ListUtil;
subs = [{A B C},    /* subs$1 is a vector */
       {1 2, 3 4},  /* subs$2 is a matrix */
       [4, 5:6]];   /* subs$3 is a list */&lt;BR /&gt;&lt;BR /&gt;call ListPrint(subs);  /* print the entire list */
&lt;BR /&gt;/* or go through item by item and decide what to do */
do j = 1 to ListLen(subs);
   d = ListGetItem(subs,j);
   print j;
   if type(d)='N' | type(d)='C' then
      print d;
   else if type(d)='L' then
      call ListPrint(d);
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For more about lists and printing, see p 7-8 of &lt;A href="http://support.sas.com/resources/papers/proceedings17/SAS0420-2017.pdf" target="_self"&gt;Wicklin (2017)&lt;/A&gt;, and also the question on p. 19.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 18:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/615415#M4956</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-06T18:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: ListGetItem Command-Type of matrix error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/642253#M5056</link>
      <description>&lt;P&gt;Has this issue been resolved? If so, please close it. Otherwise, let us know what other questions you might have.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 14:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/ListGetItem-Command-Type-of-matrix-error/m-p/642253#M5056</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-04-23T14:37:34Z</dc:date>
    </item>
  </channel>
</rss>

