<?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: Is there a way to tell SAS to not retain data when using arrays? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800585#M314985</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13600"&gt;@n6&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is one more situation where array elements are retained: if one or more of them are assigned &lt;EM&gt;initial values&lt;/EM&gt;&amp;nbsp;(see &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm#p0ipqmvg7jid2xn1408suxfvlnc5" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;). That is, if you define an array of dimension 1000 and supply an initial value for one of these variables, this variable &lt;EM&gt;and all the 999 others&lt;/EM&gt; will be retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is what happened in your code, consider using an explicit RETAIN statement or assignment statements to supply the initial values or reset those variables to missing (e.g., with CALL MISSING) that you don't want to be retained.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 09:13:52 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-03-07T09:13:52Z</dc:date>
    <item>
      <title>Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800538#M314952</link>
      <description>&lt;P&gt;I haven't used arrays recently but I would've sworn that data in them didn't retain.&amp;nbsp; But then I wrote some code using arrays and was getting unexpected answers and I finally figured out it was because the data was being retained when it went to the next observation.&amp;nbsp; It took me awhile to figure it out because I didn't even consider that a possibility because I was so sure that that wasn't how arrays work in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the question is, is there a simple way to tell SAS to not retain data when I'm using arrays?&amp;nbsp; Any info is appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 04:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800538#M314952</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2022-03-07T04:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800545#M314957</link>
      <description>Maybe you could try using a _temporary_ option, for example, array a {3} _temporary_ 1 2 3.</description>
      <pubDate>Mon, 07 Mar 2022 04:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800545#M314957</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2022-03-07T04:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800549#M314959</link>
      <description>&lt;P&gt;Array statements do no have any impact on whether variables are retained.&amp;nbsp; But _TEMPORARY_ arrays, which do not use actual variables, are retained.&lt;/P&gt;
&lt;P&gt;The other way that variables will be retained is if they coming from an input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to prevent variables in an array from being retained make sure they are NEW permanent variables.&amp;nbsp; If you don't want them written to the output dataset then DROP them.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 05:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800549#M314959</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-07T05:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800561#M314967</link>
      <description>&lt;P&gt;As said before_temporary_ array values are by defualt retained. But variables as expressed in array are not retained. Array values are refreshed as data step iterates. Here is an example and see the LOG.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	set sashelp.class;
	array k[*] age height weight;
	put k[1] = k[2] = k[3] =;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 06:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800561#M314967</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2022-03-07T06:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800566#M314970</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17813"&gt;@KachiM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As said before_temporary_ array values are by defualt retained. But variables as expressed in array are not retained. Array values are refreshed as data step iterates. Here is an example and see the LOG.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	set sashelp.class;
	array k[*] age height weight;
	put k[1] = k[2] = k[3] =;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So that is an example of an array where the values ARE retained.&amp;nbsp; But since the data step is so simple it is hard to tell since the SET statement overwrites the retained value with the values from the next observation read.&lt;/P&gt;
&lt;P&gt;To see it in action add a PUT AGE= statement BEFORE the SET statement.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 06:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800566#M314970</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-07T06:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800569#M314973</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I understood that a&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Retain statement defined by SAS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 06:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800569#M314973</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2022-03-07T06:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800572#M314975</link>
      <description>&lt;P&gt;Please show the code, so that we can suggest improvements.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 06:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800572#M314975</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-03-07T06:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800585#M314985</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13600"&gt;@n6&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is one more situation where array elements are retained: if one or more of them are assigned &lt;EM&gt;initial values&lt;/EM&gt;&amp;nbsp;(see &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm#p0ipqmvg7jid2xn1408suxfvlnc5" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;). That is, if you define an array of dimension 1000 and supply an initial value for one of these variables, this variable &lt;EM&gt;and all the 999 others&lt;/EM&gt; will be retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is what happened in your code, consider using an explicit RETAIN statement or assignment statements to supply the initial values or reset those variables to missing (e.g., with CALL MISSING) that you don't want to be retained.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 09:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800585#M314985</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-03-07T09:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to tell SAS to not retain data when using arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800740#M315053</link>
      <description>&lt;P&gt;Reset the values when done or when you need them "not retained".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without a real concrete example it is hard to provide an optimal method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not clear whether you want to set values to missing or to a specific list of values. So example code where you are using a temporary array that needs to be "not retained" with a description of the rules for when "not retained" is desired would help a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the documentation&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-syntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-otherArgGroup"&gt;
&lt;DIV id="n118z82e4o3t4an1lxxpoyoaq43e" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;DIV id="n05zzkgtkwqngin1xjnw8f6xebys" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;FONT style="background-color: #fcdec0;"&gt;_TEMPORARY_&lt;/FONT&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;creates a list of temporary data elements.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryRange"&gt;Range&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;Temporary data elements can be numeric or character.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD rowspan="6" class="xis-summaryTip"&gt;Tips&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;Temporary data elements behave like DATA step variables with these exceptions:&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;They do not have names. Refer to temporary data elements by the array name and dimension.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;They do not appear in the output data set.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;You cannot use the special subscript asterisk (*) to refer to all the elements.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;&lt;U&gt;&lt;FONT color="#800080"&gt;&lt;STRONG&gt;Temporary data element values are always automatically retained, rather than being reset to missing at the beginning of the next iteration of the DATA step.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;Arrays of temporary elements are useful when the only purpose for creating an array is to perform a calculation. To preserve the result of the calculation, assign it to a variable. You can improve performance time by using temporary data elements.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 21:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-tell-SAS-to-not-retain-data-when-using-arrays/m-p/800740#M315053</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-07T21:33:32Z</dc:date>
    </item>
  </channel>
</rss>

