<?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: Reusing same expression for multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694214#M211702</link>
    <description>&lt;P&gt;DO OVER may still work, but it is unsupported and not listed in the SAS documentation. Better to use a supported syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(v);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2020 12:00:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-10-26T12:00:23Z</dc:date>
    <item>
      <title>Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694183#M211694</link>
      <description>&lt;P&gt;I need to remove multiple undesirable symbols, chars, and spaces, from multiple variables.&lt;/P&gt;
&lt;P&gt;This is the kind of code I'm using so far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do unwanted = '"', ';', '|';
		VAR1 = compbl(transtrn(compress(VAR1,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR2 = compbl(transtrn(compress(VAR2,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR3 = compbl(transtrn(compress(VAR3,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR4 = compbl(transtrn(compress(VAR4,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR5 = compbl(transtrn(compress(VAR5,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR6 = compbl(transtrn(compress(VAR6,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;		VAR7 = compbl(transtrn(compress(VAR7,,'c'), strip(unwanted), trimn('')));&lt;BR /&gt;end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, the same extact expression is used for all 7 variables.&lt;/P&gt;
&lt;P&gt;Can you please suggest a more tidy way to set this up, so that I only need to use the expression 1 place?&lt;/P&gt;
&lt;P&gt;EDIT: Don't know why is the code isn't displayed properly, &lt;A href="https://i.ibb.co/HDtkWxh/Skjermbilde.png" target="_self"&gt;here's a screenshot&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 09:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694183#M211694</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2020-10-26T09:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694185#M211695</link>
      <description>&lt;P&gt;Exactly, what&amp;nbsp;&lt;SPAN&gt;symbols and chars do you want to remove?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 08:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694185#M211695</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-10-26T08:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694190#M211697</link>
      <description>&lt;P&gt;Need to remove the pipe-symbol (|), semicolons, double quotation marks, carriage returns, and double spaces. Eventually more, I'm sure. The code seems to work well though. I'm just curious about how I can set it up so that I can reuse the same expressions for multiple variables instead of listing it (compbl etc.) on each row.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 09:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694190#M211697</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2020-10-26T09:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694194#M211698</link>
      <description>&lt;P&gt;Use an array and do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    array v $30 var1-var10;
    do over v;
        v = 'abc|} [de f{€")(/    "ab||c';
    end;
run;

data want;
   set have;
   array v var1-var10;
   do over v;
      v = compbl(prxchange('s/[";\|]//', -1, v));
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2020 09:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694194#M211698</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-10-26T09:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694214#M211702</link>
      <description>&lt;P&gt;DO OVER may still work, but it is unsupported and not listed in the SAS documentation. Better to use a supported syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(v);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 12:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694214#M211702</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-26T12:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing same expression for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694219#M211703</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;thank you. Yes, the implicitly subscripted array and the 'do over' syntax are not documented anymore.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call me old-fashioned, but I still like to use the implicit array from time to time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Mainly because of the simplicity of the syntax.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 11:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reusing-same-expression-for-multiple-variables/m-p/694219#M211703</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-10-26T11:58:42Z</dc:date>
    </item>
  </channel>
</rss>

