<?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 error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796868#M255751</link>
    <description>&lt;P&gt;It's frustrating that we have to request this over and over from you, but please post the log in the window that appears when you click on the &amp;lt;/&amp;gt; icon. This preserves the formatting of the log and makes it much more readable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Also, don't be stingy, show us the entire log for this DATA step, not selected lines.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 13:53:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-02-17T13:53:11Z</dc:date>
    <item>
      <title>Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796864#M255749</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the reason for the error please?&lt;/P&gt;
&lt;P&gt;35 DROP AAA{i};&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, -, :, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;36 rename BBB{i}=AAA{i};&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: -, :, =.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;37 end;&lt;BR /&gt;38 run;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data want;
set have;
array AAA {12} Revenue1_sum Revenue2_sum Revenue3_sum Revenue4_sum Revenue5_sum Revenue6_sum
Revenue7_sum Revenue8_sum Revenue9_sum Revenue10_sum Revenue11_sum Revenue12_sum;
array BBB {12} Revenue1_sum_ Revenue2_sum_ Revenue3_sum_ Revenue4_sum_ Revenue5_sum_ Revenue6_sum_
Revenue7_sum_ Revenue8_sum_ Revenue9_sum_ Revenue10_sum_ Revenue11_sum_ Revenue12_sum_;
do i = 1 to 12;
if AAA{i} &amp;lt;0 and AAA{i} ne .  then BBB{i} =0;
DROP  AAA{i};
rename BBB{i}=AAA{i};
end;
run;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 13:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796864#M255749</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-02-17T13:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796868#M255751</link>
      <description>&lt;P&gt;It's frustrating that we have to request this over and over from you, but please post the log in the window that appears when you click on the &amp;lt;/&amp;gt; icon. This preserves the formatting of the log and makes it much more readable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Also, don't be stingy, show us the entire log for this DATA step, not selected lines.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 13:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796868#M255751</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T13:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796870#M255752</link>
      <description>&lt;P&gt;Unfortunately, this kind of syntax is not supported. You can not reference an array, or part of an array in a Drop or Rename Statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DROP  AAA{i};
rename BBB{i}=AAA{i};&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 13:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796870#M255752</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-17T13:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796873#M255753</link>
      <description>&lt;P&gt;The data step looks as if you should read the documentation explaining the statements "drop" and "rename". Hint: it is not possible to execute them conditionally.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 13:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796873#M255753</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-02-17T13:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796899#M255770</link>
      <description>&lt;P&gt;DROP and RENAME are compile-time statements, when i has not yet a value, so how should the data step compiler know which array element to drop?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 15:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796899#M255770</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T15:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796901#M255772</link>
      <description>So  what is the way to drop and rename 12 variables in efficiency way without  writing long code?&lt;BR /&gt;What modification is required  to my code to get the desired  results?</description>
      <pubDate>Thu, 17 Feb 2022 15:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796901#M255772</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-02-17T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796912#M255777</link>
      <description>&lt;P&gt;You can list variables using short cut lists which rely on a prefix. Using varying suffixes this type of operation is not supported and bad design given that SAS works well with prefixes.&amp;nbsp;&lt;BR /&gt;So &lt;STRONG&gt;redesign your process&lt;/STRONG&gt; so you have unique prefixes and then drop them using the colon operator or - or -- notation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AKA rename your array variables such that they have unique prefixes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;So what is the way to drop and rename 12 variables in efficiency way without writing long code?&lt;BR /&gt;What modification is required to my code to get the desired results?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 16:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796912#M255777</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-17T16:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796914#M255779</link>
      <description>&lt;P&gt;Like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
array AAA {12} 
Revenue1_sum Revenue2_sum Revenue3_sum Revenue4_sum Revenue5_sum Revenue6_sum
Revenue7_sum Revenue8_sum Revenue9_sum Revenue10_sum Revenue11_sum Revenue12_sum;

do i = 1 to 3;
  do j = 1 to 12;
    t+1;
    AAA[j] = t;
  end;
  output;
end;
run;
proc print data = work.have;
run;

proc sql;
  select cats(name,"=",name,"_")
  into :list separated by " "
  from dictionary.columns
  where libname = "WORK"
    and memname = "HAVE"
    and upcase(name) like 'REVENUE%'
;
quit;

proc datasets lib = work;
  modify have;
    rename &amp;amp;list.;
  run;
quit;
proc print data = work.have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 16:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796914#M255779</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-02-17T16:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796918#M255782</link>
      <description>&lt;P&gt;Or just drop the second array entirely as well as the rename/drop. It's not required in the code you've shown.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 16:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/796918#M255782</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-17T16:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/797175#M255882</link>
      <description>&lt;P&gt;Need only one array to check and replace. Reeza has already said this. I give an illustration with 3 cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Revenue1_sum = 1;
Revenue2_sum = -0.1;
Revenue3_sum = -0.2;
run;
data want;
	set have;
	array aaa[3] Revenue1_sum Revenue2_sum Revenue3_sum;
	do i = 1 to 3;
		if aaa[i] &amp;lt; 0 and aaa[i] ne . then aaa[i] = 0;
		
	end;
drop i;
run;

proc print data = want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 09:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-error/m-p/797175#M255882</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2022-02-18T09:04:15Z</dc:date>
    </item>
  </channel>
</rss>

