<?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: define a module to read different variable in one dataset in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203162#M2111</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. I think read({name sex}) would also work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Apr 2015 15:06:49 GMT</pubDate>
    <dc:creator>Hanyu</dc:creator>
    <dc:date>2015-04-24T15:06:49Z</dc:date>
    <item>
      <title>define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203155#M2104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can we define a module which has variable names as arguments and reads the variables into a matrix? I tried the following code and it does not work. &lt;/P&gt;&lt;P&gt;Suppose the variable "a" is a variable in dataset "y" and I want to read a into matrix su. The reason I want to do this is that I have many variables in y and I want to repeat my estimation for different variable.&amp;nbsp; Thank you in advance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;start read(s);&lt;/P&gt;&lt;P&gt;use y;&lt;/P&gt;&lt;P&gt;read all var{s} into su;&lt;/P&gt;&lt;P&gt;close y;&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;run read(a);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: s is not in the scope of variables for the data set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 10:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203155#M2104</guid>
      <dc:creator>Hanyu</dc:creator>
      <dc:date>2015-04-24T10:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203156#M2105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you put characters into curly braces, you are defining a vector of character values.&lt;/P&gt;&lt;P&gt;Thus {s} is equal to "s". &lt;/P&gt;&lt;P&gt;Your READ statement should be&lt;/P&gt;&lt;P&gt;read all var s into su;&amp;nbsp; /* no braces */&lt;/P&gt;&lt;P&gt;which means "read the variables that are contained in the character vector s."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make it work, you have to pass in a character matrix.&amp;nbsp; In your example, you would call it as&lt;/P&gt;&lt;P&gt;run read("a");&amp;nbsp;&amp;nbsp;&amp;nbsp; /* notice the quotes on "a"; it is a string */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also suggest that you make your function return the su matrix by using&lt;/P&gt;&lt;P&gt;return(su); &lt;/P&gt;&lt;P&gt;and calling the function as&lt;/P&gt;&lt;P&gt;X = read("a"); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 11:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203156#M2105</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-04-24T11:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203157#M2106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Dr.&amp;nbsp; May I ask one more question? I want to also create dataset according to arguments of a module.&amp;nbsp; My attempt is the following&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;proc iml;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;start store_est(a,b);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;estimate=T(1:30);&lt;/P&gt;&lt;P&gt;std=T(1:30);&lt;/P&gt;&lt;P&gt;display=estimate||std;&lt;/P&gt;&lt;P&gt;create estimate_a_b from display;&lt;/P&gt;&lt;P&gt;append from display;&lt;/P&gt;&lt;P&gt;close estimate_a_b;&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;store module=store_est;&lt;/P&gt;&lt;P&gt;run store_est(s1,s2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the code does not work. Is there a way to parametrize the dataset name in the module?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203157#M2106</guid>
      <dc:creator>Hanyu</dc:creator>
      <dc:date>2015-04-24T12:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203158#M2107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. The basic operation is explained in this article &lt;A href="http://blogs.sas.com/content/iml/2013/07/29/read-data-sets-array-names.html" title="http://blogs.sas.com/content/iml/2013/07/29/read-data-sets-array-names.html"&gt;http://blogs.sas.com/content/iml/2013/07/29/read-data-sets-array-names.html&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically you want to construct the data set name as a string by concatenating a root name with the strings contains in a and b.&amp;nbsp; The following statements create the data set "estimate_1_2":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;start store_est(a,b);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; estimate=T(1:30);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; std=T(1:30);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; display=estimate||std;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DSName = "estimate_" + a + "_" + b;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; create (DSName) from display;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; append from display;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; close (DSName);&lt;BR /&gt;finish;&lt;BR /&gt;store module=store_est;&lt;/P&gt;&lt;P&gt;run store_est("1","2");&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203158#M2107</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-04-24T12:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203159#M2108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Dr. Regarding my first question, I am now trying to read two variables into one matrix. I am a bit struggling with this operation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc iml;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;start read(s);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;use y;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;read all var s into su;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;close y;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;finish;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run read("a b");&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If I define s to be something like "a b" or "a,b", sas say the variable a b is not in the dataset. Could you help me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203159#M2108</guid>
      <dc:creator>Hanyu</dc:creator>
      <dc:date>2015-04-24T12:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203160#M2109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is starting to turn into "please write my program for me." I think you would benefit from taking an hour or two to learn about how to create and use SAS/IML character vectors.&lt;/P&gt;&lt;P&gt;The Doc (free):&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_languagechap_toc.htm" title="http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_languagechap_toc.htm"&gt;SAS/IML(R) 13.1 User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;A good book ($$): &lt;A href="http://www.sas.com/store/prodBK_63119_en.html" title="http://www.sas.com/store/prodBK_63119_en.html"&gt;Statistical Programming with SAS/IML® Software&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The book has a FREE excerpt that has information about elementary matrix operations such as you are asking:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sas.com/storefront/aux/en/spstatprogiml/63119_excerpt.pdf" title="http://www.sas.com/storefront/aux/en/spstatprogiml/63119_excerpt.pdf"&gt;http://www.sas.com/storefront/aux/en/spstatprogiml/63119_excerpt.pdf&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 12:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203160#M2109</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-04-24T12:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203161#M2110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assign value to that parameter matrix :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;

proc iml;
start read(s);
use sashelp.class;
read all var s into su;
close sashelp.class;
print su;
finish;
run read({'name' 'sex'});
quit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 14:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203161#M2110</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-24T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: define a module to read different variable in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203162#M2111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. I think read({name sex}) would also work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 15:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/define-a-module-to-read-different-variable-in-one-dataset/m-p/203162#M2111</guid>
      <dc:creator>Hanyu</dc:creator>
      <dc:date>2015-04-24T15:06:49Z</dc:date>
    </item>
  </channel>
</rss>

