<?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: using indexing to change contents of a SAS/IML sublist in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-indexing-to-change-contents-of-a-SAS-IML-sublist/m-p/749612#M5496</link>
    <description>&lt;P&gt;Pay attention to the types of the variables. You wrote&lt;/P&gt;
&lt;PRE&gt;L_char1 = L_char$'temp1'[ { 3 2 1 } ] ;   /* create new list of reversed character entries */&lt;/PRE&gt;
&lt;P&gt;but actually&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;L_char1 is a character vector (so shouldn't have an L_ prefix). Thus, you can't use the $ operator on it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;The next line has several errors. There is no named item 'temp'. You can't replace part of an item; you can only replace the item. You are attempting to assign a value that is longer than the character vector can hold.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Assuming your goal is to change the second element of L_char$'temp1', you can do it like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;c = L_char$'temp1';       /* extract item */
print (nleng(c));         /* length is only 6 */
c[2] = 'middle string' ;  /* change value (it will be truncated at 6 characters) */
L_char$'temp1' = c;       /* update item */
call struct( L_char ) ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 15:52:24 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2021-06-22T15:52:24Z</dc:date>
    <item>
      <title>using indexing to change contents of a SAS/IML sublist</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-indexing-to-change-contents-of-a-SAS-IML-sublist/m-p/749586#M5495</link>
      <description>&lt;P&gt;I want to use indexing to change the contents of a SAS/IML sublist. I do not know if I am making syntax errors or if SAS/IML does not do what I want it to do because I am exceeding the product's design specs. Here is my code example:&lt;/P&gt;&lt;PRE&gt;proc iml ;&lt;BR /&gt;package load ListUtil ;&lt;BR /&gt;&lt;BR /&gt;charVec = { 'abcde' 'fgh' 'ijklmn' } ;    /* define 1x3 character vector */&lt;BR /&gt;&lt;BR /&gt;L_char = [ #'charVec'=charVec ] ;         /* define list comprising one item of 1x3 character entries */&lt;BR /&gt;call struct( L_char ) ;&lt;BR /&gt;&lt;BR /&gt;temp = L_char$'charVec' ;                 /* create 1x3 character matrix from list item */&lt;BR /&gt;call struct( temp ) ;&lt;BR /&gt;&lt;BR /&gt;do i = 1 to ncol( temp ) ; &lt;BR /&gt;   print i 'temp[' i ']=' ( temp[ i ] ) ; /* print contents of temp as individual entries to demonstrate scalar addressing */&lt;BR /&gt;end ;&lt;BR /&gt;&lt;BR /&gt;L_char =[ #'temp1'=temp ] ;               /* create new list comprising one item of 1x3 character entries */&lt;BR /&gt;call struct( L_char ) ;&lt;BR /&gt;&lt;BR /&gt;L_char1 = L_char$'temp1'[ { 3 2 1 } ] ;   /* create new list of reversed character entries */&lt;BR /&gt;&lt;BR /&gt;L_char1$('temp'[ 2 ]) = 'middle string' ; /* attempt to change contents of subitem using indexing */&lt;BR /&gt;&lt;BR /&gt;call struct( L_char1 ) ;&lt;BR /&gt;&lt;BR /&gt;quit &amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The IML interpreter generates an error when I try to index into the L_char1$'charVec' sublist:&lt;/P&gt;&lt;PRE class="sasLog"&gt;ERROR: (execution) Invalid subscript or subscript out of range.&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;I do not know how to create the correct syntax to change an entry in the sublist temp1 in the list L_char1. Am I trying to do something that is not possible within IML as currently defined, or do I merely not understand the syntactic niceties?&lt;/P&gt;&lt;P&gt;TIA,&lt;/P&gt;&lt;P&gt;Ross Bettinger&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 15:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-indexing-to-change-contents-of-a-SAS-IML-sublist/m-p/749586#M5495</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2021-06-22T15:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: using indexing to change contents of a SAS/IML sublist</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-indexing-to-change-contents-of-a-SAS-IML-sublist/m-p/749612#M5496</link>
      <description>&lt;P&gt;Pay attention to the types of the variables. You wrote&lt;/P&gt;
&lt;PRE&gt;L_char1 = L_char$'temp1'[ { 3 2 1 } ] ;   /* create new list of reversed character entries */&lt;/PRE&gt;
&lt;P&gt;but actually&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;L_char1 is a character vector (so shouldn't have an L_ prefix). Thus, you can't use the $ operator on it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;The next line has several errors. There is no named item 'temp'. You can't replace part of an item; you can only replace the item. You are attempting to assign a value that is longer than the character vector can hold.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Assuming your goal is to change the second element of L_char$'temp1', you can do it like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;c = L_char$'temp1';       /* extract item */
print (nleng(c));         /* length is only 6 */
c[2] = 'middle string' ;  /* change value (it will be truncated at 6 characters) */
L_char$'temp1' = c;       /* update item */
call struct( L_char ) ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 15:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-indexing-to-change-contents-of-a-SAS-IML-sublist/m-p/749612#M5496</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-06-22T15:52:24Z</dc:date>
    </item>
  </channel>
</rss>

