<?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 Use formula for values of matrix elements in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Use-formula-for-values-of-matrix-elements/m-p/386209#M3680</link>
    <description>&lt;P&gt;Is there a way to write the 5th line below so that it works (while keeping it within a single expression / single line) ?&lt;/P&gt;&lt;P&gt;More generally, how can a vector be initiated by specifying formulas instead of values for each element?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	x = j(3,2,.);
	do i = 1 to nrow(x);
		/*this doesn't work*/
		x[i,] = { i 0 };

		/*this does work, but it's an extra line */
		x[i,1] = i;
		x[i,2] = 0;
	end;
quit&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2017 11:00:24 GMT</pubDate>
    <dc:creator>MDaniel</dc:creator>
    <dc:date>2017-08-08T11:00:24Z</dc:date>
    <item>
      <title>Use formula for values of matrix elements</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Use-formula-for-values-of-matrix-elements/m-p/386209#M3680</link>
      <description>&lt;P&gt;Is there a way to write the 5th line below so that it works (while keeping it within a single expression / single line) ?&lt;/P&gt;&lt;P&gt;More generally, how can a vector be initiated by specifying formulas instead of values for each element?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	x = j(3,2,.);
	do i = 1 to nrow(x);
		/*this doesn't work*/
		x[i,] = { i 0 };

		/*this does work, but it's an extra line */
		x[i,1] = i;
		x[i,2] = 0;
	end;
quit&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 11:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Use-formula-for-values-of-matrix-elements/m-p/386209#M3680</guid>
      <dc:creator>MDaniel</dc:creator>
      <dc:date>2017-08-08T11:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use formula for values of matrix elements</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Use-formula-for-values-of-matrix-elements/m-p/386216#M3681</link>
      <description>&lt;P&gt;The direct answer to your question is to use the horizontal concatenation operator (||)&lt;/P&gt;
&lt;P&gt;x[i,] = i || 0;&lt;/P&gt;
&lt;P&gt;as described in the article &lt;A href="http://blogs.sas.com/content/iml/2011/02/21/how-to-build-a-vector-from-expressions.html" target="_self"&gt;"How to build a vector from&amp;nbsp;expressions."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, for this example, you don't need a loop at all:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x1 = T( 1:3 );
x2 = j(nrow(x1), 1, 0);
x = x1 || x2;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 11:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Use-formula-for-values-of-matrix-elements/m-p/386216#M3681</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-08T11:33:22Z</dc:date>
    </item>
  </channel>
</rss>

