<?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 Update a sas dataset with proc iml in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84870#M492</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to update a sas dataset using proc iml but with no success.&lt;/P&gt;&lt;P&gt;his is the code I wrote:&lt;/P&gt;&lt;P&gt;data a1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a='c1'; a1=1; a2=2; a3=5; wr=3;output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a='c2';a1=3; a2=1; a3=4; wr=5;output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc iml;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; edit a1&amp;nbsp; VAR {A1 A2 A3 WR} ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read&amp;nbsp; all var {A1 A2 A3}&amp;nbsp; into nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read&amp;nbsp; all var { wr}&amp;nbsp; into wr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print&amp;nbsp; nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do i=1 to 2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j=1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i^=j then nn[i,j]=nn[i,j]*1/(1-wr&lt;I&gt;/2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace point i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; replace ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print wr nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; close a1 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But at the end even if the nn matrix is correct a1 dataset is not updated.&lt;/P&gt;&lt;P&gt;I know that my question is rather easy, but I'm new with this procedure.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Federica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Aug 2012 11:14:32 GMT</pubDate>
    <dc:creator>e3flator</dc:creator>
    <dc:date>2012-08-06T11:14:32Z</dc:date>
    <item>
      <title>Update a sas dataset with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84870#M492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to update a sas dataset using proc iml but with no success.&lt;/P&gt;&lt;P&gt;his is the code I wrote:&lt;/P&gt;&lt;P&gt;data a1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a='c1'; a1=1; a2=2; a3=5; wr=3;output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a='c2';a1=3; a2=1; a3=4; wr=5;output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc iml;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; edit a1&amp;nbsp; VAR {A1 A2 A3 WR} ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read&amp;nbsp; all var {A1 A2 A3}&amp;nbsp; into nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read&amp;nbsp; all var { wr}&amp;nbsp; into wr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print&amp;nbsp; nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do i=1 to 2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j=1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i^=j then nn[i,j]=nn[i,j]*1/(1-wr&lt;I&gt;/2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace point i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; replace ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print wr nn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; close a1 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But at the end even if the nn matrix is correct a1 dataset is not updated.&lt;/P&gt;&lt;P&gt;I know that my question is rather easy, but I'm new with this procedure.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Federica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 11:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84870#M492</guid>
      <dc:creator>e3flator</dc:creator>
      <dc:date>2012-08-06T11:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Update a sas dataset with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84871#M493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two errors here:&lt;/P&gt;&lt;P&gt;1) The default "range" for the REPLACE stmt is CURRENT, so the second call to REPLACE (outside the loop) isn't doing what you want.&lt;/P&gt;&lt;P&gt;2) The REPLACE stmt replaces variables that are in common to the data set and the IML program.&amp;nbsp; Inside the loop, you are trying to update the A1, A2, and A3 variables, but you haven''t changed those vectors. You are updating the NN matrix, but this matrix is not "linked" or connected to the A1-A3 variables, even though it was created from them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find that it is easiest and fastest to use REPLACE ALL rather than REPLACE CURRENT or REPLACE POINT.&amp;nbsp; I recommend that you update the NN matrix, then copy the columns of NN back into A1-A3, then use REPLACE ALL, as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do j=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i^=j then nn[i,j]=nn[i,j]*1/(1-wr&lt;I&gt;/2);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;A1 = nn[,1]; A2 = nn[,2]; A3 = nn[,3];&lt;/P&gt;&lt;P&gt;replace all var{A1 A2 A3};&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 13:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84871#M493</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-08-06T13:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Update a sas dataset with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84872#M494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Rick.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2012 10:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Update-a-sas-dataset-with-proc-iml/m-p/84872#M494</guid>
      <dc:creator>e3flator</dc:creator>
      <dc:date>2012-08-07T10:48:32Z</dc:date>
    </item>
  </channel>
</rss>

