<?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: Matrix with strings in IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359592#M3497</link>
    <description>&lt;P&gt;As Ian says, please tell us what you are trying to accomplish. The easiest approach might be to have a matrix of "values" and another matrix of "labels",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In answer to your question,&amp;nbsp;matrices are either ALL NUMERIC or ALL CHARACTER. However, &lt;A href="http://blogs.sas.com/content/iml/2017/03/22/data-tables-in-sasiml.html" target="_self"&gt;SAS/IML supports the "Table" data structure&lt;/A&gt;, which is like an in-memory version of a data set. A table can contain columns&amp;nbsp;of either data type. &amp;nbsp;Tables are new in SAS/IML 14.2 (SAS 9.4m4).&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2017 10:02:26 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-05-18T10:02:26Z</dc:date>
    <item>
      <title>Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359579#M3494</link>
      <description>&lt;P&gt;I wanted to create a matrix with nested loops where elements have numeric values but also concatenated string values, however I get this error: "&lt;SPAN&gt;ERROR: (execution) Invalid argument to function."&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I built a small example that expresses the problem:&lt;/P&gt;&lt;PRE&gt;proc iml;
/* data example */&lt;BR /&gt;pds = {0.3, 0.4, 0.8};
&lt;BR /&gt;M = J(3,1,0);
do i=1 to 3;
M[i,1] = 'PD' + char(pds[i]);
end; 

print M;
quit;&lt;/PRE&gt;&lt;P&gt;As I understand it: it is not possible to write a string to a matrix element?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for suggestions how to solve this!&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 09:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359579#M3494</guid>
      <dc:creator>philip_</dc:creator>
      <dc:date>2017-05-18T09:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359584#M3495</link>
      <description>&lt;P&gt;The matrix M&amp;nbsp;would have to be defined as a character for this to work.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* data example */
pds = {0.3, 0.4, 0.8};

M = J(3,1,'       ');
do i=1 to 3;
M[i,1] = 'PD' + char(pds[i],4,1);
end; 

print M;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But surely this makes it difficult to recover the numeric value later on.&amp;nbsp; So why not have one numeric and one character matrix?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 09:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359584#M3495</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-05-18T09:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359589#M3496</link>
      <description>&lt;P&gt;Ian, thank you! This helps a lot, but brings up two related questions:&lt;/P&gt;&lt;P&gt;- is it possible to have a mixed matrix within IML (i.e. one column is numeric, and one character) ?&lt;/P&gt;&lt;P&gt;- do I need to&amp;nbsp;print the blank spaces (' &amp;nbsp; ') in the initialization of the matrix or is there also a shortcut?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Regarding your suggestion with the two separate matrices: this is just some "weird" flag that is required, the numerical value would still be given in an additional column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 09:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359589#M3496</guid>
      <dc:creator>philip_</dc:creator>
      <dc:date>2017-05-18T09:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359592#M3497</link>
      <description>&lt;P&gt;As Ian says, please tell us what you are trying to accomplish. The easiest approach might be to have a matrix of "values" and another matrix of "labels",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In answer to your question,&amp;nbsp;matrices are either ALL NUMERIC or ALL CHARACTER. However, &lt;A href="http://blogs.sas.com/content/iml/2017/03/22/data-tables-in-sasiml.html" target="_self"&gt;SAS/IML supports the "Table" data structure&lt;/A&gt;, which is like an in-memory version of a data set. A table can contain columns&amp;nbsp;of either data type. &amp;nbsp;Tables are new in SAS/IML 14.2 (SAS 9.4m4).&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 10:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359592#M3497</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-05-18T10:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359595#M3498</link>
      <description>&lt;P&gt;Regarding the other question :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;M = J(3,1,BlankStr(6));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would be a way of declaring a character matrix with a specific string length.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 10:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359595#M3498</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-05-18T10:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix with strings in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359627#M3499</link>
      <description>&lt;PRE&gt;
proc iml;
/* data example */
pds = {0.3, 0.4, 0.8};

M = 'PD ' + strip(char(pds));


print M;
quit;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2017 12:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrix-with-strings-in-IML/m-p/359627#M3499</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-18T12:18:11Z</dc:date>
    </item>
  </channel>
</rss>

