<?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: Delete the last few character in variable name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546931#M151507</link>
    <description>&lt;P&gt;Thanks a lot for your code, PaigeMiller!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2019 15:55:38 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2019-03-28T15:55:38Z</dc:date>
    <item>
      <title>Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546907#M151499</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a dataset where a number of variables end in "_2019".&lt;/P&gt;
&lt;P&gt;I would like to remove the suffix.&lt;/P&gt;
&lt;P&gt;The problem is that the name has multiple _&lt;/P&gt;
&lt;P&gt;Any help is very much appreciated?&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input id_ab_x var_1 s_01_03&lt;FONT color="#FF0000"&gt;_2019&lt;/FONT&gt; xy_2_05&lt;FONT color="#FF0000"&gt;_2019&lt;/FONT&gt;;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1 2 1 1&lt;/P&gt;
&lt;P&gt;2 2 3 4&lt;/P&gt;
&lt;P&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546907#M151499</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-28T14:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546910#M151500</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a dataset where a number of variables end in "_2019".&lt;/P&gt;
&lt;P&gt;I would like to remove the suffix.&lt;/P&gt;
&lt;P&gt;The problem is that the name has multiple _&lt;/P&gt;
&lt;P&gt;Any help is very much appreciated?&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input id_ab_x var_1 s_01_03&lt;FONT color="#FF0000"&gt;_2019&lt;/FONT&gt; xy_2_05&lt;FONT color="#FF0000"&gt;_2019&lt;/FONT&gt;;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1 2 1 1&lt;/P&gt;
&lt;P&gt;2 2 3 4&lt;/P&gt;
&lt;P&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not sure I understand the problem. In your code, you can simply delete the parts you don't want. In bulk, you can delete the text _2019 from wherever it is found, using the Edit-&amp;gt;Replace menu command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your problem is really that you have existing data sets with dozens/hundreds/thousands of variable names that you need to change (which is certainly not what you stated), then we'd need to know a lot more about the problem. And we'd also need to know if you are delete only "_2019" from the variable name, or if you want to delete the LAST text after the last underscore (and delete that last underscore as well). In other words, we need an exact problem description clearly delineating what needs to be deleted.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546910#M151500</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-28T14:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546912#M151501</link>
      <description>&lt;P&gt;Thanks for asking.&lt;/P&gt;
&lt;P&gt;I have new data each day and there are 30+ variables ending with _2019.&lt;/P&gt;
&lt;P&gt;Names are different from time to time so I need to clear that part by SAS.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546912#M151501</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-28T15:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546913#M151502</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have out=_contents_ noprint;
run;
proc sql noprint;
    select cats(name,'=',tranwrd(name,'_2019','')) into :renames 
        separated by ' ' from _contents_ where find(name,'_2019')&amp;gt;0;
quit;
%put &amp;amp;=renames;

proc datasets library=work nolist;
    modify have;
    rename &amp;amp;renames;
    delete _contents_;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code will fail if the text '_2019' appears elsewhere&amp;nbsp;(not at the end of the variable name) in the variable names.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546913#M151502</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-28T15:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546931#M151507</link>
      <description>&lt;P&gt;Thanks a lot for your code, PaigeMiller!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/546931#M151507</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-28T15:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last few character in variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/651442#M195460</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am working on a similar issues, however I have a character string '_v2' that appears at the end of the variable name for some variables, but in the middle for others. Is there a way to modify this code to remove that string from anywhere in the variable name.&lt;BR /&gt;&lt;BR /&gt;For example I have&lt;BR /&gt;id_info_v2&lt;BR /&gt;diary_type_v2____1 - diary_type_v2___4&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Thu, 28 May 2020 16:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-few-character-in-variable-name/m-p/651442#M195460</guid>
      <dc:creator>BlairWhitty</dc:creator>
      <dc:date>2020-05-28T16:04:29Z</dc:date>
    </item>
  </channel>
</rss>

