<?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: loop in iml taking a long time to run - is a more efficient method possible? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81762#M483</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;This appears to be the best so far.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;iml&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This is the weight matrix for one month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begw={ -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;13&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;19&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begw; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This is the weight matrix for another month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endw={ -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endw; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*These would be the permnos for weight matrix in month 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begp={&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*These would be the permnos for weight matrix in month 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endp={&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; begp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This merges permnos and weights;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;beg=begp||begw;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;end=endp||endw;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; beg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This eliminates rows from beg that do not contain permnos in end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;newbeg=beg[t(loc(element(beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))),];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This creates a matrix of permnos in end not included in beg with zeros as weights;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;addbeg=t(setdif(end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))||j(nrow(t(setdif(end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))),&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This creates a new beg matrix;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;finalbeg=newbeg//addbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; sortndx(endx, end, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endsort=end[endx,];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; sortndx(begx,finalbeg, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begsort=finalbeg[begx,];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; newbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; addbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; finalbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endsort;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; begsort;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="mso-fareast-language: EN-US; mso-bidi-language: AR-SA; line-height: 115%; color: navy; font-size: 10pt; background: white; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; font-family: 'Courier New'; mso-fareast-font-family: Calibri;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt; mso-bidi-language: AR-SA; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-font-family: Calibri;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Dec 2012 14:54:52 GMT</pubDate>
    <dc:creator>opti_miser</dc:creator>
    <dc:date>2012-12-13T14:54:52Z</dc:date>
    <item>
      <title>loop in iml taking a long time to run - is a more efficient method possible?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81761#M482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have attached a simplified version of the code I am using in a much larger data set.&amp;nbsp; It is a loop in iml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code takes a long time to run as a result of the loop.&amp;nbsp; I was wondering if there is a more efficient way to achieve the same thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it would be helpful, I can attach the more complex version of the code.&amp;nbsp; It is really the same thing, but for a much larger set of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help you can offer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Ted Moorman&#xD;
&#xD;
*This is the weight matrix for one month;&#xD;
m1={ 3 , &#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 , &#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp; }; &#xD;
 print m1; &#xD;
&#xD;
*This is the weight matrix for another month;&#xD;
 m2={ 2 , &#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, &#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 }; &#xD;
 print m2; &#xD;
&#xD;
*These would be the permnos for weight matrix in month 1;&#xD;
p1={'a','b','c'};&#xD;
&#xD;
*These would be the permnos for weight matrix in month 2;&#xD;
p2={'c','d','e'};&#xD;
&#xD;
print p1;&#xD;
print p2;&#xD;
&#xD;
*This would be all of the permnos in the data set;&amp;nbsp; &#xD;
*This vector could be obtained with the unique statement;&#xD;
p={'a','b','c','d','e'};&#xD;
print p;&#xD;
&#xD;
&#xD;
*NOTE: The loop is just for one month;&#xD;
&#xD;
*newweight is the new weight matrix to be created;&#xD;
newweight = j(nrow(p),1);&#xD;
do i = 1 to nrow(p);&#xD;
&#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newweight&lt;I&gt;=0;&#xD;
&#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do j = 1 to nrow(m1);&#xD;
&#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if p&lt;I&gt;=p1&lt;J&gt; then newweight&lt;I&gt;=m1&lt;J&gt;;&#xD;
&#xD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end;&#xD;
&#xD;
end;&#xD;
&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 15:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81761#M482</guid>
      <dc:creator>opti_miser</dc:creator>
      <dc:date>2012-11-27T15:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: loop in iml taking a long time to run - is a more efficient method possible?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81762#M483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;This appears to be the best so far.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;iml&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This is the weight matrix for one month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begw={ -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;13&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;19&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begw; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This is the weight matrix for another month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endw={ -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endw; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*These would be the permnos for weight matrix in month 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begp={&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*These would be the permnos for weight matrix in month 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endp={&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; begp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This merges permnos and weights;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;beg=begp||begw;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;end=endp||endw;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; beg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This eliminates rows from beg that do not contain permnos in end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;newbeg=beg[t(loc(element(beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))),];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This creates a matrix of permnos in end not included in beg with zeros as weights;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;addbeg=t(setdif(end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))||j(nrow(t(setdif(end[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;],beg[,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;]))),&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;*This creates a new beg matrix;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;finalbeg=newbeg//addbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; sortndx(endx, end, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;endsort=end[endx,];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; sortndx(begx,finalbeg, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;begsort=finalbeg[begx,];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; newbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; addbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; finalbeg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; endsort;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; begsort;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="mso-fareast-language: EN-US; mso-bidi-language: AR-SA; line-height: 115%; color: navy; font-size: 10pt; background: white; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; font-family: 'Courier New'; mso-fareast-font-family: Calibri;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt; mso-bidi-language: AR-SA; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-fareast-theme-font: minor-latin; mso-fareast-font-family: Calibri;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 14:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81762#M483</guid>
      <dc:creator>opti_miser</dc:creator>
      <dc:date>2012-12-13T14:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: loop in iml taking a long time to run - is a more efficient method possible?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81763#M484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) You can get rid of the transpose function T().&amp;nbsp; It is not needed for NEWBEG=... and you can use ncol(setdif(...)) instead of nrow(t(setdif(...)))&lt;/P&gt;&lt;P&gt;2) You never use the second column of BEG and END, so you can really do all of this with indices to rows of BEGP and ENDP&lt;/P&gt;&lt;P&gt;3) I haven't measured it, but I suspect it is slightly faster to call SORT rather than SORTNDX followed by using the row indices to sort. So you might want to try it: &lt;/P&gt;&lt;P&gt;endsort = end;&lt;/P&gt;&lt;P&gt;call sort(endsort, 1);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 14:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/loop-in-iml-taking-a-long-time-to-run-is-a-more-efficient-method/m-p/81763#M484</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-01-02T14:55:57Z</dc:date>
    </item>
  </channel>
</rss>

