<?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: Naming a Variable Number of Matrices in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314341#M3104</link>
    <description>&lt;P&gt;What do you specifically mean by a subset from a matrix? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Nov 2016 17:59:33 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2016-11-25T17:59:33Z</dc:date>
    <item>
      <title>Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314340#M3103</link>
      <description>&lt;P&gt;I'm going to select N subsets from a matrix in a DO loop.&lt;BR /&gt;&lt;BR /&gt;N is variable, let's say 5;&lt;BR /&gt;&lt;BR /&gt;Any tips on how to name the subsets: SUB1, SUB2, SUB3, SUB4, SUB5 ?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 17:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314340#M3103</guid>
      <dc:creator>stevo642</dc:creator>
      <dc:date>2016-11-25T17:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314341#M3104</link>
      <description>&lt;P&gt;What do you specifically mean by a subset from a matrix? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 17:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314341#M3104</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-25T17:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314378#M3105</link>
      <description>&lt;P&gt;I rarely name the subsets. In a loop you can extract the first subset, do what you want with it (for example, compute its mean) and store the result. Then you extract the next subset and store its results, etc, until all subsets have been handled. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a reminder that you should pre-allocate the results matrix for efficiency, see&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2015/02/16/friends-dont-let-friends-concatenate-results-inside-a-loop.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2015/02/16/friends-dont-let-friends-concatenate-results-inside-a-loop.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 23:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314378#M3105</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-11-25T23:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314413#M3106</link>
      <description>&lt;PRE&gt;

proc iml;
x=j(10,5);
call randgen(x,'normal');

names='sub1':'sub5';
do i=1 to ncol(x);
 call valset(names[i],x[,i]);
end;

show names;
print sub1,sub2,sub3,sub4,sub5;
quit;


&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Nov 2016 03:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314413#M3106</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-26T03:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314843#M3107</link>
      <description>RE: SUBSET&lt;BR /&gt;&lt;BR /&gt;The full matrix (say, ALLDAT) is numerical stock data by stock &amp;amp; date: maybe 250K rows and 75 columns.&lt;BR /&gt;&lt;BR /&gt;E.g., 2500 rows by 75 columns of data for "AAPL", one row for each date // 2500 rows of data for "AXP" // ...&lt;BR /&gt;&lt;BR /&gt;A separate 250K X 1 stock tickers array (say, ALLTKR) tells me which rows of ALLDAT correspond to which stocks. So the 1st 2500 rows are "AAPL" data, the next 2500 rows are "AXP" data, etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm testing a stock trading strategy on a subset of ALLDAT. Let's say the subset is the 30 stocks currently in the Dow Jones Industrials Average (DJIA).&lt;BR /&gt;&lt;BR /&gt;I'd specify the 30 tickers of the DJIA: {"AAPL" "AXP" "BA" "CAT" "CSCO" "CVX" "DD" "DIS" "GE" "GS" "HD" "IBM" "INTC" "JNJ" "JPM" "KO" "MCD" "MMM" "MRK" "MSFT" "NKE" "PFE" "PG" "TRV" "UNH" "UTX" "V" "VZ" "WMT" "XOM"}&lt;BR /&gt;&lt;BR /&gt;Then I'd like to extract the rows of ALLDAT for each of those tickers into a matrix named as the ticker: extract 2500 "AAPL" rows into a matrix named AAPL, 2500 "AXP" rows into AXP, etc.&lt;BR /&gt;&lt;BR /&gt;Within a DO loop over the dates I would perform calculations, compare, and select stocks for a portfolio.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I could probably skip the creation of the 30 submatrices by using pointers in ALLTKR to reference rows of ALLDAT but for debugging purposes having separate matrices may be very helpful.&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Nov 2016 15:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314843#M3107</guid>
      <dc:creator>stevo642</dc:creator>
      <dc:date>2016-11-28T15:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Naming a Variable Number of Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314857#M3108</link>
      <description>&lt;P&gt;A useful approach is to read each stock, analyze each stock, and then go on to the next stock. After reading all the data and computing statistics for each stock, you can do additional analysis that compares different stocks. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the following loop reads one stock into X. &amp;nbsp;If computes various statistics for each stock. After the loop is over, I have a matrix called RESULTS that contains all the information that I need to build my portfolio. &amp;nbsp;The following program uses the following techniques:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.sas.com/content/iml/2013/01/21/reading-big-data.html" target="_self"&gt;How to read big data in blocks&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.sas.com/content/iml/2016/04/04/where-clause-in-sasiml.html" target="_self"&gt;How to use the WHERE clause to read subsets of a data set&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/10/01/access-rows-or-columns-of-a-matrix-by-names.html" target="_self"&gt;How to assign matrix attributes so you can access rows or columns by names&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
StockNames = {"IBM" "Intel" "Microsoft"}; /*{"AAPL" "AXP" ... "WMT" "XOM"}*/
results = j(3, ncol(StockNames), .);
mattrib results rowname={"Mean" "Stddev" "MaxVol"}
                colname=StockNames;
use Sashelp.stocks;
/* http://blogs.sas.com/content/iml/2013/01/21/reading-big-data.html */
do ID = 1 to ncol(StockNames);
   /* read in data for each stock */
   /* http://blogs.sas.com/content/iml/2016/04/04/where-clause-in-sasiml.html */
   read all var _NUM_ into X[colname=varNames]
            where(Stock=(StockNames[ID]));
   /* http://blogs.sas.com/content/iml/2012/10/01/access-rows-or-columns-of-a-matrix-by-names.html */
   results["Mean", ID] = mean(X[,"Close"]);  
   results["Stddev", ID] = std(X[,"Close"]);  
   results["MaxVol", ID] = max(X[,"Volume"]);  
end;
close;

print results;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Nov 2016 15:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Naming-a-Variable-Number-of-Matrices/m-p/314857#M3108</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-11-28T15:56:25Z</dc:date>
    </item>
  </channel>
</rss>

