<?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 Repating a vector in a vector form in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Repating-a-vector-in-a-vector-form/m-p/108605#M811</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have a vector &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v = [i &lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to repeat a vector in a vector format couple of times:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v=[i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;Actually I would like to use this in reshaping a matrix to a vector. but I want to add a column by the variable name as the first two columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;z = [&lt;/P&gt;&lt;P&gt;1 2 3&lt;/P&gt;&lt;P&gt;4 5 6&lt;/P&gt;&lt;P&gt;7 8 9]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rowname = [ a b c]&lt;/P&gt;&lt;P&gt;calname = [i j k]&lt;/P&gt;&lt;P&gt;I am using Z = shape(Z, ncol*nrow, 1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a table looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a i 1&lt;/P&gt;&lt;P&gt;a j 2&lt;/P&gt;&lt;P&gt;a k 3&lt;/P&gt;&lt;P&gt;b i 4&lt;/P&gt;&lt;P&gt;b j 5&lt;/P&gt;&lt;P&gt;b k 6&lt;/P&gt;&lt;P&gt;c i 7&lt;/P&gt;&lt;P&gt;c j 8&lt;/P&gt;&lt;P&gt;c k 9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jul 2012 18:13:08 GMT</pubDate>
    <dc:creator>goliPSU</dc:creator>
    <dc:date>2012-07-16T18:13:08Z</dc:date>
    <item>
      <title>Repating a vector in a vector form</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Repating-a-vector-in-a-vector-form/m-p/108605#M811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have a vector &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v = [i &lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to repeat a vector in a vector format couple of times:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v=[i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;i&lt;/P&gt;&lt;P&gt;j&lt;/P&gt;&lt;P&gt;k&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;Actually I would like to use this in reshaping a matrix to a vector. but I want to add a column by the variable name as the first two columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;z = [&lt;/P&gt;&lt;P&gt;1 2 3&lt;/P&gt;&lt;P&gt;4 5 6&lt;/P&gt;&lt;P&gt;7 8 9]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rowname = [ a b c]&lt;/P&gt;&lt;P&gt;calname = [i j k]&lt;/P&gt;&lt;P&gt;I am using Z = shape(Z, ncol*nrow, 1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a table looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a i 1&lt;/P&gt;&lt;P&gt;a j 2&lt;/P&gt;&lt;P&gt;a k 3&lt;/P&gt;&lt;P&gt;b i 4&lt;/P&gt;&lt;P&gt;b j 5&lt;/P&gt;&lt;P&gt;b k 6&lt;/P&gt;&lt;P&gt;c i 7&lt;/P&gt;&lt;P&gt;c j 8&lt;/P&gt;&lt;P&gt;c k 9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 18:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Repating-a-vector-in-a-vector-form/m-p/108605#M811</guid>
      <dc:creator>goliPSU</dc:creator>
      <dc:date>2012-07-16T18:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Repating a vector in a vector form</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Repating-a-vector-in-a-vector-form/m-p/108606#M812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want to use the REPEAT function, as discussed in the Getting Started chapter of my book.&lt;/P&gt;&lt;P&gt;Several examples are here: &lt;A class="active_link" href="http://blogs.sas.com/content/iml/2012/06/27/create-an-id-vector-for-repeated-measurements/" title="http://blogs.sas.com/content/iml/2012/06/27/create-an-id-vector-for-repeated-measurements/"&gt;http://blogs.sas.com/content/iml/2012/06/27/create-an-id-vector-for-repeated-measurements/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the first two columns, you should read about the very useful Define2DGrid function, which wraps up some of the REPEAT and SHAPE functionality: &lt;A class="active_link" href="http://blogs.sas.com/content/iml/2011/01/21/how-to-create-a-grid-of-values/" title="http://blogs.sas.com/content/iml/2011/01/21/how-to-create-a-grid-of-values/"&gt;http://blogs.sas.com/content/iml/2011/01/21/how-to-create-a-grid-of-values/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can use that function to generate the indices for the first two columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ij = Define2DGrid(1, 3, 3, 1, 3, 3);&lt;/P&gt;&lt;P&gt;i = ij[,1];&amp;nbsp; j = ij[,2];&lt;/P&gt;&lt;P&gt;rname={a b c};&lt;/P&gt;&lt;P&gt;cname = {i j k};&lt;/P&gt;&lt;P&gt;c1 = rname&lt;J&gt;;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;c2 = cname&lt;I&gt;;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 18:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Repating-a-vector-in-a-vector-form/m-p/108606#M812</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-07-16T18:41:35Z</dc:date>
    </item>
  </channel>
</rss>

