<?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  the values, how to read the obs from the dataset in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272749#M2776</link>
    <description>&lt;P&gt;My suggestion to use SHAPE works as long as all the groups have the same size &lt;STRONG&gt;and&lt;/STRONG&gt;&amp;nbsp;the SAS data set is sorted by group.&amp;nbsp;&amp;nbsp; Then you could use code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  use mydata;
  read all var {y} into y;
  z = t( shape(y, 3, 11) );
  print z;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2016 14:31:08 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2016-05-24T14:31:08Z</dc:date>
    <item>
      <title>read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272714#M2773</link>
      <description>&lt;P&gt;I need to read the values of the dependent variable y from the sas data I created into an n * K matrix, where n is the number of obs in each group and k is the number of levels of my cateogrial variable.&amp;nbsp;&amp;nbsp; i need first to write k statements to read the obs from the dataset into k column vectors of dimension nX1, then needd to write a statment that horizontally concatenates these k columns vectors to form the n * k matrix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;w&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272714#M2773</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-24T13:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272743#M2774</link>
      <description>&lt;P&gt;You may need to supply some more details on how the SAS data set is structured to get better help.&amp;nbsp; However,&amp;nbsp;my feeling is that you would be&amp;nbsp;better to read the variable y into one vector, and then manipulate this is IML.&amp;nbsp; For example look at the SHAPE function which can be used to turn a vector into a matrix.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272743#M2774</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2016-05-24T14:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272745#M2775</link>
      <description>&lt;P&gt;a SAS data set that contains one continuous variable (&lt;EM&gt;y&lt;/EM&gt;) and one categorical variable (&lt;EM&gt;x&lt;/EM&gt;) with at least three levels. These are to be used as&amp;nbsp;my continuous dependent variable and categorical independent variable in&amp;nbsp;my single factor ANOVA model&lt;/P&gt;&lt;P&gt;then i will need to do sas iml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have three groups, each has 11 obs&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272745#M2775</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-24T14:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272749#M2776</link>
      <description>&lt;P&gt;My suggestion to use SHAPE works as long as all the groups have the same size &lt;STRONG&gt;and&lt;/STRONG&gt;&amp;nbsp;the SAS data set is sorted by group.&amp;nbsp;&amp;nbsp; Then you could use code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  use mydata;
  read all var {y} into y;
  z = t( shape(y, 3, 11) );
  print z;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272749#M2776</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2016-05-24T14:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272751#M2777</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272751#M2777</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-24T14:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272753#M2778</link>
      <description>&lt;P&gt;or even simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;z = &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_langref_sect437.htm" target="_self"&gt;shapecol&lt;/A&gt;(y, 11);&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272753#M2778</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-05-24T14:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272754#M2779</link>
      <description>&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 14:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/272754#M2779</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-24T14:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273048#M2787</link>
      <description>&lt;P&gt;Then I realize I might need alternative code, that is, do not use 11, 3, but use a more general code, so that it can be fit for other similiar kind of dataset as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, if others have simiar dataset, but instead of 11 obs, they have 20 obs, five categories, another dataset have 50 obs, four categories, can I have a more general code so that the code can&amp;nbsp;be&amp;nbsp;used for other datasets as well,&amp;nbsp;"one size fits all"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273048#M2787</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-25T15:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273054#M2788</link>
      <description>&lt;P&gt;You need to know either how many categories or how many obsevations.&amp;nbsp; You also need to make sure that each group has the same number of elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best situation is if you have a categorical variable that tells you the group that each observations is associated with. Then you could do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;read all var {Group y};&lt;/P&gt;
&lt;P&gt;numGroups = ncol(unique(Group));&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;z = shapecol(y, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;, numGroups);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;If you don't have a GROUP variable, you'll have to input the numGroups value manually.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273054#M2788</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-05-25T15:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273059#M2789</link>
      <description>&lt;P&gt;I do have a variable "Tem", it is a charactor not a numeric. It has three catogories&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;iml&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;reset&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; print;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;use&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;read&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; all &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; {tem y};&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;numGroups = ncol(unique(tem));&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;z = shapecol(y, &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;, numGroups);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ERROR: Y is not in the scope of variables for the data set.&lt;/P&gt;&lt;P&gt;does it mean that I have to convert the charactor to numeric variable?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 16:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273059#M2789</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-25T16:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273094#M2790</link>
      <description>&lt;P&gt;No, the error is saying that you do not a variable named 'Y'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some data that shows you how it works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do tem = 'A', 'B', 'C';
   do i = 1 to 5;
      y = rand("uniform");
      output;
   end;
end;

proc iml; 
use have;
read all var {tem y};
numGroups = ncol(unique(tem));
z = shapecol(y, 0, numGroups);
print z;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By the way, you mistakenly choose your own post as the solution. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 18:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273094#M2790</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-05-25T18:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273100#M2791</link>
      <description>&lt;P&gt;Thank you very much. This does show me how it works. . But my question remained unsolved, if I need a general code, rather than to type the number 3 and 11&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 18:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273100#M2791</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-25T18:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273103#M2792</link>
      <description>&lt;P&gt;If you look at my last message, you will see that there are&amp;nbsp;no hard-coded values anywhere. &amp;nbsp;It should solve the&amp;nbsp;problem&amp;nbsp;as you have explained it.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 18:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273103#M2792</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-05-25T18:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: read  the values, how to read the obs from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273109#M2793</link>
      <description>&lt;P&gt;That is so good. Great learning experience! Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 18:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/read-the-values-how-to-read-the-obs-from-the-dataset/m-p/273109#M2793</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-05-25T18:57:38Z</dc:date>
    </item>
  </channel>
</rss>

