<?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: Replace or remove a specific character string from all the variable names in the table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774828#M246293</link>
    <description>&lt;P&gt;If there is a variable named X_USED_CAR_LOAN_DPD_LAST_&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;_MTH_CNT_DBT in your dataset, then transposing it from wide to long will solve the trouble with fancy long names automatically.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Oct 2021 07:11:06 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-10-18T07:11:06Z</dc:date>
    <item>
      <title>Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774724#M246253</link>
      <description>&lt;P&gt;In a SAS table, there are more than 100 columns with variable name length of more than 32 characters, instead of renaming all the variables manually, I want to write the code that will replace or remove specific character strings from all the columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example in the below-mentioned variable, I want to remove character strings "LAST_" and "MTH_" from the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="0" width="593" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="340" /&gt;&lt;COL width="253" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="415.59375px" height="30px" class="xl69"&gt;Existing Variable Name&lt;/TD&gt;
&lt;TD width="323.125px" height="30px" class="xl70"&gt;New Variable Name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="415.59375px" height="30px" class="xl71"&gt;X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_SUB&lt;/TD&gt;
&lt;TD width="323.125px" height="30px" class="xl72"&gt;X_USED_CAR_LOAN_DPD_12_CNT_SUB&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="415.59375px" height="30px" class="xl71"&gt;X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_DBT&lt;/TD&gt;
&lt;TD width="323.125px" height="30px" class="xl72"&gt;X_USED_CAR_LOAN_DPD_12_CNT_DBT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="415.59375px" height="30px" class="xl71"&gt;X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_LSS&lt;/TD&gt;
&lt;TD width="323.125px" height="30px" class="xl72"&gt;X_USED_CAR_LOAN_DPD_12_CNT_LSS&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="415.59375px" height="30px" class="xl73"&gt;X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_XXX&lt;/TD&gt;
&lt;TD width="323.125px" height="30px" class="xl74"&gt;X_USED_CAR_LOAN_DPD_12_CNT_XXX&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Note:- This is not an actual table, I just took four variable names for explanation purpose&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I rename the variable names will the label name change as well, currently variable names and label names are the same?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 14:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774724#M246253</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-10-17T14:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774725#M246254</link>
      <description>&lt;P&gt;Are you talking about doing something to the actual variable names in a SAS data set, or doing something to the text strings in the table you showed us? These are two very different tasks, its not clear which you mean.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 14:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774725#M246254</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-17T14:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774727#M246255</link>
      <description>I want to actually replace the SAS table variable name, text string was just an example of how the code is supposed to work. Sorry for the confusion, will rephrase the question itself.</description>
      <pubDate>Sun, 17 Oct 2021 14:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774727#M246255</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-10-17T14:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774728#M246256</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temporary;
    set sashelp.vcolumn(where=(libname='yourlibraryname' and memname='yourdatasetname'));
    newname=tranwrd(name,'last_','');
    newname=tranwrd(newname,'mth_','');
run;
proc sql noprint;
    select distinct cats(name,'=',compress(newname)) into :renames separated by ' '
    from temporary;
quit;
proc datasets library=yourlibraryname nolist;
     modify yourdatasetname;
     rename &amp;amp;renames;
run;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where you will have to replace &lt;FONT face="courier new,courier"&gt;yourlibraryname&lt;/FONT&gt; with the actual name of your SAS library, and you will have to replace &lt;FONT face="courier new,courier"&gt;yourdatasetname&lt;/FONT&gt; with the actual name of your data set.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 14:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774728#M246256</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-17T14:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774828#M246293</link>
      <description>&lt;P&gt;If there is a variable named X_USED_CAR_LOAN_DPD_LAST_&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;_MTH_CNT_DBT in your dataset, then transposing it from wide to long will solve the trouble with fancy long names automatically.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 07:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774828#M246293</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-10-18T07:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774831#M246296</link>
      <description>Sorry I did not understand your solution, can you please elaborate.</description>
      <pubDate>Mon, 18 Oct 2021 07:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774831#M246296</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-10-18T07:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774834#M246298</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316224"&gt;@Saurabh_Rana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry I did not understand your solution, can you please elaborate.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have variables named&amp;nbsp;&lt;FONT face="courier new,courier"&gt;X_USED_CAR_LOAN_DPD_LAST_11_MTH_CNT_SUB&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_SUB&lt;/FONT&gt; then you should think about transposing the data to move information, in this case the month, into a variable, allowing easier usage of the data in most subsequent steps.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 07:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774834#M246298</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-10-18T07:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Replace or remove a specific character string from all the variable names in the table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774870#M246308</link>
      <description>&lt;PRE&gt;data have;
input old $40.;
cards;
X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_SUB	
X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_DBT	
X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_LSS	
X_USED_CAR_LOAN_DPD_LAST_12_MTH_CNT_XXX
;
data want;
 set have;
 new=prxchange('s/last_|mth_//i',-1,old);
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 12:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-or-remove-a-specific-character-string-from-all-the/m-p/774870#M246308</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-18T12:41:39Z</dc:date>
    </item>
  </channel>
</rss>

