<?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 Do loops in Proc IML in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100564#M5187</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to automate a do loop in a Proc IML statement, but I cant figure out why the matrix called ''vwap'' doesnt update properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have put two versions of the code below.&amp;nbsp; The first is just the standard code with each iteration hard coded, the second is the code with the do loop inserted.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please help me understand why this do loop is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;reset print;&lt;/P&gt;&lt;P&gt;xxx = {10 2 3.01, 10 3 3.05, 10 1 3.07};&lt;/P&gt;&lt;P&gt;volume = xxx[1,2];&lt;/P&gt;&lt;P&gt;price = xxx[1,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;volume = xxx[2,2];&lt;/P&gt;&lt;P&gt;price = xxx[2,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;volume = xxx[3,2];&lt;/P&gt;&lt;P&gt;price = xxx[3,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****** The second version of the code with the do loop inserted - VWAP does not update for some reason.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;reset print;&lt;/P&gt;&lt;P&gt;xxx = {10 2 2.91, 10 3 3.05, 10 1 3.07};&lt;/P&gt;&lt;P&gt;do i = 1 to 3;&lt;/P&gt;&lt;P&gt;volume = xxx[i,2];&lt;/P&gt;&lt;P&gt;price = xxx[i,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Jun 2013 19:49:29 GMT</pubDate>
    <dc:creator>AaronAardvaark</dc:creator>
    <dc:date>2013-06-09T19:49:29Z</dc:date>
    <item>
      <title>Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100564#M5187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to automate a do loop in a Proc IML statement, but I cant figure out why the matrix called ''vwap'' doesnt update properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have put two versions of the code below.&amp;nbsp; The first is just the standard code with each iteration hard coded, the second is the code with the do loop inserted.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please help me understand why this do loop is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;reset print;&lt;/P&gt;&lt;P&gt;xxx = {10 2 3.01, 10 3 3.05, 10 1 3.07};&lt;/P&gt;&lt;P&gt;volume = xxx[1,2];&lt;/P&gt;&lt;P&gt;price = xxx[1,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;volume = xxx[2,2];&lt;/P&gt;&lt;P&gt;price = xxx[2,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;volume = xxx[3,2];&lt;/P&gt;&lt;P&gt;price = xxx[3,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****** The second version of the code with the do loop inserted - VWAP does not update for some reason.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;reset print;&lt;/P&gt;&lt;P&gt;xxx = {10 2 2.91, 10 3 3.05, 10 1 3.07};&lt;/P&gt;&lt;P&gt;do i = 1 to 3;&lt;/P&gt;&lt;P&gt;volume = xxx[i,2];&lt;/P&gt;&lt;P&gt;price = xxx[i,3];&lt;/P&gt;&lt;P&gt;call symput ('volume', char(volume));&lt;/P&gt;&lt;P&gt;call symput ('price', char(price));&lt;/P&gt;&lt;P&gt;vwap = {[&amp;amp;volume] &amp;amp;price}`;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jun 2013 19:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100564#M5187</guid>
      <dc:creator>AaronAardvaark</dc:creator>
      <dc:date>2013-06-09T19:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100565#M5188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why are you creating these macro variables in the first place?&amp;nbsp; If you are trying to extract the columns from the matrix, XXX, to create the matrix, VWAP, why not simply do the following?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VWAP=XXX[,2:3];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, if you also need the matrices, VOLUME and PRICE, why not do the following?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VOLUME=XXX[,2];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRICE=XXX[,3];&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 12:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100565#M5188</guid>
      <dc:creator>1zmm</dc:creator>
      <dc:date>2013-06-11T12:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100566#M5189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not trying to extract the columns - this is a part of a bigger program I am writing whereby I am taking some data and using the matrix language to manipulate it before sending it back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have simplified the issue as much as I can to make it easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using information from each row of the matrix xxx to create a vector (VWAP) whose length changes as each row is considered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is why does putting it in a loop stop it from working when the attributes of volume and price are exactly the same in both versions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 12:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100566#M5189</guid>
      <dc:creator>AaronAardvaark</dc:creator>
      <dc:date>2013-06-11T12:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100567#M5190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the first, "hard-coded" version work in your bigger problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, perhaps the problem is that the CALL SYMPUT statements do NOT work to create the macro variables, &amp;amp;VOLUME and &amp;amp;PRICE, in the same PROC IML step.&amp;nbsp; These statements would not work in a DATA step.&amp;nbsp; You may have to explain more details about the bigger problem you are trying to solve.&amp;nbsp; Or, submit this problem to the separate community SAS thread on PROC IML.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 13:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100567#M5190</guid>
      <dc:creator>1zmm</dc:creator>
      <dc:date>2013-06-11T13:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100568#M5191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first code works perfectly, that is why it is so perplexing.&amp;nbsp; It should be easy to just set a do statement to iterate to the end of the matrix, but when I do the code stops working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both price and volume have exactly the same attributes in each section of code, which is why I just cant understand why it no longer works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 14:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100568#M5191</guid>
      <dc:creator>AaronAardvaark</dc:creator>
      <dc:date>2013-06-11T14:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops in Proc IML</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100569#M5192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linking to the answer as posted in the SAS/IML Support Community: &lt;A _jive_internal="true" href="https://communities.sas.com/message/170978#170978"&gt;https://communities.sas.com/message/170978#170978&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jun 2013 11:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Do-loops-in-Proc-IML/m-p/100569#M5192</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-06-14T11:29:31Z</dc:date>
    </item>
  </channel>
</rss>

