<?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 Can I create an add a suffix to a pre-defined array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641840#M191381</link>
    <description>&lt;P&gt;Suppose I have an array with inconsistent variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example I have:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;an array with dim = 3, and the variables are called "brand", "model", "type"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way for me to create another array which renames these variables (whilst retaining the original variables).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my head, I'm trying something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array  to_rename {3} revenue expenses assets;
array  new {3} newvar1-newvar3;
array new_name {3} newnames1-newnames3;
DO i = 1 to 3;
 new(i) = to_rename(i)/USD;
 new_name(i) = cats(new(i),'_USD');
END;
DROP I;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So, the output would be an additional 3 variables, entitled:&lt;/P&gt;&lt;P&gt;revenue_USD, expenses_USD, assets_USD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 08:21:29 GMT</pubDate>
    <dc:creator>UniversitySas</dc:creator>
    <dc:date>2020-04-22T08:21:29Z</dc:date>
    <item>
      <title>Can I create an add a suffix to a pre-defined array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641840#M191381</link>
      <description>&lt;P&gt;Suppose I have an array with inconsistent variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example I have:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;an array with dim = 3, and the variables are called "brand", "model", "type"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way for me to create another array which renames these variables (whilst retaining the original variables).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my head, I'm trying something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array  to_rename {3} revenue expenses assets;
array  new {3} newvar1-newvar3;
array new_name {3} newnames1-newnames3;
DO i = 1 to 3;
 new(i) = to_rename(i)/USD;
 new_name(i) = cats(new(i),'_USD');
END;
DROP I;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So, the output would be an additional 3 variables, entitled:&lt;/P&gt;&lt;P&gt;revenue_USD, expenses_USD, assets_USD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641840#M191381</guid>
      <dc:creator>UniversitySas</dc:creator>
      <dc:date>2020-04-22T08:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create an add a suffix to a pre-defined array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641850#M191389</link>
      <description>&lt;P&gt;If names are inconsistent and you already know the target of rename you can do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have
        have(rename=(revenue=revenue_usd  
             expenses=expenses_usd   &lt;BR /&gt;             assets=assets_usd));
by;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641850#M191389</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-04-22T08:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create an add a suffix to a pre-defined array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641855#M191393</link>
      <description>&lt;P&gt;Here is an example which you can try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However in arrays we need to take care that we can use only either all numeric variables or all character variables.&lt;/P&gt;
&lt;P&gt;In the below example i used all numeric variables to rename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select cats(name,'_USD') into: names separated by ' ' from dictionary.columns where libname='SASHELP' and memname='CLASS' and type='num';
quit;

%put &amp;amp;names;

data class;
set sashelp.class;
array vars(*) age -- weight;
array vars2(*) &amp;amp;names;
do i = 1 to dim(vars);
vars2(i)=vars(i);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 09:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641855#M191393</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-22T09:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create an add a suffix to a pre-defined array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641991#M191456</link>
      <description>&lt;P&gt;You may want to reconsider the whole "add any suffix" idea to begin with.&lt;/P&gt;
&lt;P&gt;When you leave variables with a numeric suffix then you can use all of the LIST shortcuts such as var1 - var3. As soon as you add a suffix then you will &lt;STRONG&gt;always&lt;/STRONG&gt; have to list var1_usd var2_usd var3_usd.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might suggest that you name them Usd_1 Usd_2 and Usd_3. Use a LABEL to describe them back to something else.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 15:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-create-an-add-a-suffix-to-a-pre-defined-array/m-p/641991#M191456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-22T15:16:40Z</dc:date>
    </item>
  </channel>
</rss>

