<?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: read SAS dataset into a matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/883332#M6007</link>
    <description>&lt;P&gt;Thanks for all the hints, everyone. For now, I had to put the matrix into MATLAB to do the matrix operations; MATLAB is quite straight foward to code and I'm on an extremely tight deadline to provide some of the many answers in this project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I still need to streamline it all into SAS, since all base matrices will be estimated from a dataset containing ~1.7 million rows and growing. The project will require calculating anywhere between 40-50 different matrices from the SAS dataset, then doing all the operations.&lt;/P&gt;
&lt;P&gt;I haven't had the time to figure out how to get proc iml to READ a matrix from a dataset. If anyone has the code for this and doesn't mind sharing it, I'd really appreciate the time saving tip, I'm on a tight schedule here.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In case someone in the community is interested in Markov chains&lt;/STRONG&gt;: the 10 by 10 matrices are basic Markov transition probability matrices, all estimated from the SAS dataset with a bunch of different criteria.&amp;nbsp; Item 5 in the answer is a misunderstanding: the final goal &lt;STRONG&gt;really are scalars&lt;/STRONG&gt;, each one the expected future values of a certain index. Each scalar is the nth row of the matrix (1 by 10 vector of probabilities) multiplied by the 10 by 1 column vector of the 10 possible index values. I think picking the rows with a macro will be straightfoward to get once the matrix is read as matrix: use a vector with zeroes everywhere and a 1 in the position of the row I want to pick.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jul 2023 15:27:01 GMT</pubDate>
    <dc:creator>Angela53</dc:creator>
    <dc:date>2023-07-03T15:27:01Z</dc:date>
    <item>
      <title>read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882051#M6003</link>
      <description>&lt;P&gt;Hi! I'm new to proc iml or other SAS matrix capabilities. I couldn't find an iml manual online. First of all, I need to find out how to read a 10x10 matrix from a SAS dataset, then elevate it to several increasing powers, then save the resulting matrices as SAS datasets.&lt;/P&gt;
&lt;P&gt;Next, I need to multiply each of these matrices' rows by a 10x1 column vector and store the scalars.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is appreciated!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 23:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882051#M6003</guid>
      <dc:creator>Angela53</dc:creator>
      <dc:date>2023-06-22T23:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882055#M6004</link>
      <description>&lt;P&gt;Here's the link to the online&amp;nbsp; &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/imlug/titlepage.htm" target="_blank" rel="noopener"&gt;IML documentation&lt;/A&gt;. Have a look through it then come back with any remaining questions.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 00:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882055#M6004</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-23T00:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882102#M6005</link>
      <description>&lt;P&gt;This sounds like homework, but here are a few hints:&lt;BR /&gt;1. SAS Kiwi gave you the link to the documentation, but here is another introduction to SAS IML that is shorter:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings13/144-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/144-2013.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;See also&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2014/08/11/ten-tips-for-learning-sasiml.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2014/08/11/ten-tips-for-learning-sasiml.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2. Read from a data set into a matrix:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2012/01/16/reading-all-variables-into-a-matrix.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2012/01/16/reading-all-variables-into-a-matrix.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;3. Write to a data set from a matrix:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;4. The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/imlug/imlug_langref_sect047.htm" target="_self"&gt;matrix power operator&lt;/A&gt; enables you to multiply a matrix by itself k times. Or, if you want all powers, you can use a DO loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A = {1 -1,
    -1  2};
B = A;
do i = 2 to 5;
    B = B * A;    
    print i, B;   /* = A**i */
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;5. Multiplication by a vector will give you a VECTOR, not a scalar. Presumably, you want to multiply a column vector by a matrix. Here is a 2x2 example that uses the matrix A above:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v = {3, 4};
y = A*v;
print y;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 09:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882102#M6005</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-06-23T09:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882134#M6006</link>
      <description>Perfect homework! Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jun 2023 13:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/882134#M6006</guid>
      <dc:creator>Angela53</dc:creator>
      <dc:date>2023-06-23T13:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/883332#M6007</link>
      <description>&lt;P&gt;Thanks for all the hints, everyone. For now, I had to put the matrix into MATLAB to do the matrix operations; MATLAB is quite straight foward to code and I'm on an extremely tight deadline to provide some of the many answers in this project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I still need to streamline it all into SAS, since all base matrices will be estimated from a dataset containing ~1.7 million rows and growing. The project will require calculating anywhere between 40-50 different matrices from the SAS dataset, then doing all the operations.&lt;/P&gt;
&lt;P&gt;I haven't had the time to figure out how to get proc iml to READ a matrix from a dataset. If anyone has the code for this and doesn't mind sharing it, I'd really appreciate the time saving tip, I'm on a tight schedule here.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In case someone in the community is interested in Markov chains&lt;/STRONG&gt;: the 10 by 10 matrices are basic Markov transition probability matrices, all estimated from the SAS dataset with a bunch of different criteria.&amp;nbsp; Item 5 in the answer is a misunderstanding: the final goal &lt;STRONG&gt;really are scalars&lt;/STRONG&gt;, each one the expected future values of a certain index. Each scalar is the nth row of the matrix (1 by 10 vector of probabilities) multiplied by the 10 by 1 column vector of the 10 possible index values. I think picking the rows with a macro will be straightfoward to get once the matrix is read as matrix: use a vector with zeroes everywhere and a 1 in the position of the row I want to pick.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2023 15:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/883332#M6007</guid>
      <dc:creator>Angela53</dc:creator>
      <dc:date>2023-07-03T15:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: read SAS dataset into a matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/883336#M6008</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;how to get proc iml to READ a matrix from a dataset&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;I think we answered this question:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2012/01/16/reading-all-variables-into-a-matrix.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2012/01/16/reading-all-variables-into-a-matrix.html&lt;/A&gt;&amp;nbsp;If that doesn't answer your question, please provide an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;the 10 by 10 matrices are basic Markov transition probability matrices,&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;I assume you are using the ideas in&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2023/03/20/estimate-transition-matrix.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2023/03/20/estimate-transition-matrix.html&lt;/A&gt;&lt;BR /&gt;(or something similar) to estimate the transition matrices. If you have the transition matrices and initial distribution of states, you can use matrix multiplication to estimate the probability that the system is in any state after k transitions:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2016/07/07/markov-transition-matrices-sasiml.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2016/07/07/markov-transition-matrices-sasiml.html&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;The distribution of states enables you to answer many questions related to the probable state of the system after k transitions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have specific questions, please post your IML code and/or example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;picking the rows with a macro will be straightfoward to get&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The IML language is a full-featured programming language, so&amp;nbsp;you almost never need to use SAS macro in an IML&amp;nbsp; program. If you want the m_th row of a matrix, just extract it: &lt;FONT face="courier new,courier"&gt;row = A[m, ];&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2023 15:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-SAS-dataset-into-a-matrix/m-p/883336#M6008</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-07-03T15:58:24Z</dc:date>
    </item>
  </channel>
</rss>

