<?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 remove a prefix from every variable name in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-a-prefix-from-every-variable-name-in-a-dataset/m-p/831338#M328491</link>
    <description>&lt;P&gt;I have a bunch of datasets that have been recreated on a new server.&amp;nbsp; However, the variable names now have a four letter prefix (table name_variable name).&lt;/P&gt;
&lt;P&gt;In order for my legacy programs to read these datasets in the new server, I want to rename to variables to display without the table name prefix, thus, saving me from recoding all of my programs.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2022 20:30:54 GMT</pubDate>
    <dc:creator>chandler</dc:creator>
    <dc:date>2022-08-31T20:30:54Z</dc:date>
    <item>
      <title>how to remove a prefix from every variable name in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-a-prefix-from-every-variable-name-in-a-dataset/m-p/831338#M328491</link>
      <description>&lt;P&gt;I have a bunch of datasets that have been recreated on a new server.&amp;nbsp; However, the variable names now have a four letter prefix (table name_variable name).&lt;/P&gt;
&lt;P&gt;In order for my legacy programs to read these datasets in the new server, I want to rename to variables to display without the table name prefix, thus, saving me from recoding all of my programs.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 20:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-a-prefix-from-every-variable-name-in-a-dataset/m-p/831338#M328491</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2022-08-31T20:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove a prefix from every variable name in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-a-prefix-from-every-variable-name-in-a-dataset/m-p/831340#M328492</link>
      <description>&lt;P&gt;Use the RENAME statement (which will work for actual SAS datasets).&lt;/P&gt;
&lt;P&gt;Get the list of variables. Generate the RENAME statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do them all at once by using PROC DATASETS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=mylib._all_ noprint out=contents; run;

filename code temp;
data _null_;
  set contents;
  by memname;
  file code;
  if first.memname then put 'modify ' memname ';' / @3 'rename ' ;
  length old new $70 ;
  old=nliteral(name);
  new=nliteral(substr(name,5));
  put @5 old '=' new ;
  if last.memname then put @3 ';' / 'run;' ;
run;

proc datasets nolist lib=mylib;
%include code / source2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2022 21:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-a-prefix-from-every-variable-name-in-a-dataset/m-p/831340#M328492</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-31T21:00:21Z</dc:date>
    </item>
  </channel>
</rss>

