<?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 How to add sequence prefix to hundreds of variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410977#M100445</link>
    <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add sequence prefix to a group of variables. In my current data, my variables' names are all in the format of "_"+XXXX (four random number), for example, they are like _3452, _8342, etc. I would like to add a sequence prefix to each of my variables' name, like change them to val1_3452, val2_8342,...,.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any advice!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2017 20:15:20 GMT</pubDate>
    <dc:creator>huhuhu</dc:creator>
    <dc:date>2017-11-06T20:15:20Z</dc:date>
    <item>
      <title>How to add sequence prefix to hundreds of variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410977#M100445</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add sequence prefix to a group of variables. In my current data, my variables' names are all in the format of "_"+XXXX (four random number), for example, they are like _3452, _8342, etc. I would like to add a sequence prefix to each of my variables' name, like change them to val1_3452, val2_8342,...,.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any advice!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410977#M100445</guid>
      <dc:creator>huhuhu</dc:creator>
      <dc:date>2017-11-06T20:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to add sequence prefix to hundreds of variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410982#M100448</link>
      <description>&lt;P&gt;Do you really have to?&lt;/P&gt;
&lt;P&gt;You can use the -- to create a list of variables that are listed in order in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the approach I mentioned without doing any of this - you can list the variables in an array for one. If you want to use the Call Execute solution, again, list the array and then use VNAME to pull the variable name to push to the call execute statement, which is the solution you marked as correct in your previous question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
set have (obs=1);

array _var_list (*) first_variable -- last_variable;

do i=1 to dim(_var_list);

name = vname(_var_list(i));&lt;BR /&gt;&lt;BR /&gt;*add the call execute here with the variable name now;&lt;BR /&gt;
output;

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410982#M100448</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-06T20:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add sequence prefix to hundreds of variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410984#M100449</link>
      <description>&lt;P&gt;And if you really, really, really do want to do that, see this solution here, which does it for suffixes but can be adapted for prefixes as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/82d9f2854edc01560e0f" target="_blank"&gt;https://gist.github.com/statgeek/82d9f2854edc01560e0f&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410984#M100449</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-06T20:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add sequence prefix to hundreds of variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410988#M100452</link>
      <description>&lt;P&gt;I'm not sure I see the value gained by doing this, but a reasonably short program can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=have noprint out=names (keep=name);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data newnames;&lt;/P&gt;
&lt;P&gt;set names;&lt;/P&gt;
&lt;P&gt;newname = cats('val', _n_, name);&lt;/P&gt;
&lt;P&gt;where name =: '_';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;select trim(name) || '=' || newname into : rename_list separated by ' ' from newnames;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;rename &amp;amp;rename_list;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is untested but looks about right.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410988#M100452</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-06T20:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to add sequence prefix to hundreds of variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410991#M100453</link>
      <description>You can use _n_ and concatanate it with variabli.&lt;BR /&gt;Data new;&lt;BR /&gt;Set old;&lt;BR /&gt;X=_n_;&lt;BR /&gt;Y="var"||X||"_"||my_variable;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;You can also use catx,</description>
      <pubDate>Mon, 06 Nov 2017 20:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-sequence-prefix-to-hundreds-of-variables/m-p/410991#M100453</guid>
      <dc:creator>Yavuz</dc:creator>
      <dc:date>2017-11-06T20:42:04Z</dc:date>
    </item>
  </channel>
</rss>

