<?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: array getting updated but not data-set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25141#M4339</link>
    <description>Thanks Cynthia for the references, The problem with my requirement is that i need to change the values of some other row and not the row for which iteration is happening.</description>
    <pubDate>Fri, 29 Oct 2010 18:58:38 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-10-29T18:58:38Z</dc:date>
    <item>
      <title>array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25137#M4335</link>
      <description>Hi Guys,&lt;BR /&gt;
I am trying to update a column of a table, the values of the column are loaded into an array. &lt;BR /&gt;
But what i observe is that the array is getting updated but no the data-set, please let me know what i am doing wrong.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input id;&lt;BR /&gt;
datalines;&lt;BR /&gt;
0&lt;BR /&gt;
5&lt;BR /&gt;
1&lt;BR /&gt;
-6&lt;BR /&gt;
-1&lt;BR /&gt;
4&lt;BR /&gt;
1&lt;BR /&gt;
-7&lt;BR /&gt;
-9&lt;BR /&gt;
4&lt;BR /&gt;
run;&lt;BR /&gt;
data test1 (keep=id2);&lt;BR /&gt;
set test nobs=nobs end=eof;&lt;BR /&gt;
array a_id1(100) _temporary_;&lt;BR /&gt;
array a_id2(100) _temporary_;&lt;BR /&gt;
a_id1(_n_) = id;&lt;BR /&gt;
a_id2(_n_) = id2;&lt;BR /&gt;
if eof then &lt;BR /&gt;
do i = 1 to nobs;&lt;BR /&gt;
	a_id2(i) = a_id1(i)*100;&lt;BR /&gt;
	output test1; &lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=test1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Sanjeev</description>
      <pubDate>Fri, 29 Oct 2010 08:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25137#M4335</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-10-29T08:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25138#M4336</link>
      <description>So, what SAS code assigns a new value to ID2 in WORK.TEST (that is the only variable you have in your KEEP= list)?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 29 Oct 2010 12:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25138#M4336</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-29T12:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25139#M4337</link>
      <description>Hi Scott,&lt;BR /&gt;
I have loaded the id2 in a_id2 using the following statement.&lt;BR /&gt;
a_id2(_n_) = id2;&lt;BR /&gt;
&lt;BR /&gt;
Using the above statement i suppose we have linked id2 with the array a_id2 and whenever i change something in the array it should reflect in the data set.&lt;BR /&gt;
&lt;BR /&gt;
I am new to SAS, please forgive me for my ignorance.&lt;BR /&gt;
&lt;BR /&gt;
Sanjeev</description>
      <pubDate>Fri, 29 Oct 2010 14:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25139#M4337</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-10-29T14:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25140#M4338</link>
      <description>Hi:&lt;BR /&gt;
  You stated this assumption/desire:&lt;BR /&gt;
&lt;B&gt;&lt;U&gt;whenever i change something in the array it should reflect in the data set &lt;/U&gt;&lt;/B&gt;&lt;U&gt;&lt;/U&gt;&lt;BR /&gt;
 &lt;BR /&gt;
However, your array definitions are _temporary_ and if you consult the documentation, you will find in this example:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000739642.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000739642.htm&lt;/A&gt;&lt;BR /&gt;
the explanation that:&lt;BR /&gt;
"Although they behave like variables, temporary array elements do not have names, and they do not appear in the output data set."  Full documentation on _TEMPORARY_ is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
As shown in this example:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/773.html" target="_blank"&gt;http://support.sas.com/kb/24/773.html&lt;/A&gt;&lt;BR /&gt;
if you want to "touch" the permanent dataset variables, you must use what is in the temporary array to explicitly change the values of the dataset variables you want to change/keep.&lt;BR /&gt;
&lt;BR /&gt;
This is a good introductory paper on using ARRAYs with SAS (although, I find the documentation to be quite thorough and comprehensive, as well). &lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Studying a bit more on arrays and how they work in SAS should help you come to a resolution of your issue.&lt;BR /&gt;
  &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 29 Oct 2010 16:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25140#M4338</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-29T16:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25141#M4339</link>
      <description>Thanks Cynthia for the references, The problem with my requirement is that i need to change the values of some other row and not the row for which iteration is happening.</description>
      <pubDate>Fri, 29 Oct 2010 18:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25141#M4339</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-10-29T18:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: array getting updated but not data-set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25142#M4340</link>
      <description>If I understand correctly you really do not need the second array.  You are loading the first with original values one obs at a time.  Then using those values one at a time.  The new step becomes:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test1 (keep=id2);&lt;BR /&gt;
set test nobs=nobs end=eof;&lt;BR /&gt;
array a_id1(100) _temporary_;&lt;BR /&gt;
a_id1(_n_) = id;&lt;BR /&gt;
if eof then &lt;BR /&gt;
do i = 1 to nobs;&lt;BR /&gt;
id2 = a_id1(i)*100;&lt;BR /&gt;
output test1; &lt;BR /&gt;
end;&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
of course if this is truly not just a very simplified version of what you want, no array is needed at all.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test1 (keep=id2);&lt;BR /&gt;
set test;&lt;BR /&gt;
id2 = id*100;&lt;BR /&gt;
run;[/pre]</description>
      <pubDate>Fri, 29 Oct 2010 19:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-getting-updated-but-not-data-set/m-p/25142#M4340</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-10-29T19:18:28Z</dc:date>
    </item>
  </channel>
</rss>

