<?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 Repeat a process for multiple prefixes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Repeat-a-process-for-multiple-prefixes/m-p/932915#M366964</link>
    <description>&lt;P&gt;Hi! I'm repeating the same process for 13 prefixed and am wondering if it could be done with array methods. Here is the code I tried but got an error message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data data_wide;
set data_array;
array prefix{13} pa pb pc pd pe pf pg ph pi pj pk pl pm;
do n = 1 to 13;
	if prefix{n}_15 = . or prefix{n}_45 = . then do;
		prefix{n}_15 = .;
		prefix{n}_45 = .; 
	end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *,
              **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN,
              LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&lt;/PRE&gt;&lt;P&gt;I don't want to revert back to just copy-and-pasting the same code 13 times but how could I make the process more efficient and neat? Would appreciate any help. Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 23:35:56 GMT</pubDate>
    <dc:creator>duckieduck</dc:creator>
    <dc:date>2024-06-18T23:35:56Z</dc:date>
    <item>
      <title>Repeat a process for multiple prefixes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeat-a-process-for-multiple-prefixes/m-p/932915#M366964</link>
      <description>&lt;P&gt;Hi! I'm repeating the same process for 13 prefixed and am wondering if it could be done with array methods. Here is the code I tried but got an error message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data data_wide;
set data_array;
array prefix{13} pa pb pc pd pe pf pg ph pi pj pk pl pm;
do n = 1 to 13;
	if prefix{n}_15 = . or prefix{n}_45 = . then do;
		prefix{n}_15 = .;
		prefix{n}_45 = .; 
	end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *,
              **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN,
              LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&lt;/PRE&gt;&lt;P&gt;I don't want to revert back to just copy-and-pasting the same code 13 times but how could I make the process more efficient and neat? Would appreciate any help. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 23:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeat-a-process-for-multiple-prefixes/m-p/932915#M366964</guid>
      <dc:creator>duckieduck</dc:creator>
      <dc:date>2024-06-18T23:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a process for multiple prefixes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeat-a-process-for-multiple-prefixes/m-p/932919#M366967</link>
      <description>&lt;P&gt;I believe you are effectively trying to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 	if pa_15 = . or pa_45 = . then do;
		pa_15 = .;
		pa_45 = .; 
	end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;followed by the same for pb_15,pb_45&amp;nbsp; through pm_15,pm_45.&amp;nbsp; Two suggestions :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, don't make a do group.&amp;nbsp; Instead use code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if n(pa_15,pa_45)=1 then call missing(pa_15,pa_45);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;followed by pb through pm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, to use arrays, use this structure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  array p15 {13}  pa_15 pb_15 pc_15 pd_15 pe_15 pf_15 pg_15 
                  ph_15 pi_15 pj_15 pk_15 pl_15 pm_15;

  array p45 {13}  pa_45 pb_45 pc_45 pd_45 pe_45 pf_45 pg_45 
                  ph_45 pi_45 pj_45 pk_45 pl_45 pm_45;

  do i=1 to 13;
    if n(p15{i},p45{i})=1 then call missing(p15{i},p45{i});
  end;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To do it the way you originally conceived, you would have to use sas macro coding, which does not seem to be well-justified, given the relatively simple technique I'm suggesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit note:&amp;nbsp; the do loop above was corrected (6/19/2024, 14:00 UT).&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 14:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeat-a-process-for-multiple-prefixes/m-p/932919#M366967</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-06-19T14:02:43Z</dc:date>
    </item>
  </channel>
</rss>

