<?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: better way to rename variable names based on label in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612719#M178833</link>
    <description>&lt;P&gt;Thank you. Basically, I am looking for a better way to automatically&amp;nbsp;renaming a variable if its length over 20 characters. &amp;nbsp;I guess that several steps are needed to do so.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2019 15:52:41 GMT</pubDate>
    <dc:creator>nnl3256</dc:creator>
    <dc:date>2019-12-18T15:52:41Z</dc:date>
    <item>
      <title>better way to rename variable names based on label</title>
      <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612542#M178766</link>
      <description>Using SAS 9.4 TS Level 1M5. There are several tables in SQL server with table and field name longer than 32. We’ve reduced length of the table names, so such tablse can "be seen” in SAS library. But the longer field names are cut to 32 by SAS. I'm able to recognize original variable names by labels . How can I rename variables based on labels? For example Original Column Name: Patient_experience_national_com0 Column Label: Patient experience national comparison footnote New Column Name: nat_comp_ftnt Original Column Name: Efficient_use_of_medical_imagin0 Column Label: Efficient use of medical imaging national comparison footnote New Column Name: img_natcomp_ftnt ...</description>
      <pubDate>Tue, 17 Dec 2019 21:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612542#M178766</guid>
      <dc:creator>nnl3256</dc:creator>
      <dc:date>2019-12-17T21:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: better way to rename variable names based on label</title>
      <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612543#M178767</link>
      <description>&lt;P&gt;I don't understand what you want.&lt;/P&gt;
&lt;P&gt;If the names were changed because they were too long how do you expect to change them back to longer names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Names can be up to 32 bytes long.&amp;nbsp; Labels can be up to 256 bytes long.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 21:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612543#M178767</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-17T21:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: better way to rename variable names based on label</title>
      <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612719#M178833</link>
      <description>&lt;P&gt;Thank you. Basically, I am looking for a better way to automatically&amp;nbsp;renaming a variable if its length over 20 characters. &amp;nbsp;I guess that several steps are needed to do so.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 15:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612719#M178833</guid>
      <dc:creator>nnl3256</dc:creator>
      <dc:date>2019-12-18T15:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: better way to rename variable names based on label</title>
      <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612749#M178853</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173517"&gt;@nnl3256&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you. Basically, I am looking for a better way to automatically&amp;nbsp;renaming a variable if its length over 20 characters. &amp;nbsp;I guess that several steps are needed to do so.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The best way is to get whoever created the crazy names to begin with to come up with names that use a normal maximum length.&amp;nbsp; 20 characters sounds like a reasonable upper bound on the length of the names, hopefully most of them can use much shorter names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The normal process that people use is to turn english phrases like you have in your labels into names is to follow something like:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Remove unneeded words like A THE AND&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Replace long words with common abbreviations.&lt;/LI&gt;
&lt;LI&gt;As a last resort start appending numeric suffixes to keep names distinct&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note you could also look into modifying the process for create the longer names so that they are distinct in the first XX (for example 20) characters.&amp;nbsp; Then if you need to use an automatic process to truncate the names to fit into a system that does not allow paragraphs as names you don't have to worry about it causing name conflicts.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 17:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612749#M178853</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-18T17:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: better way to rename variable names based on label</title>
      <link>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612786#M178873</link>
      <description>&lt;P&gt;And don't forget acronyms based on recurring words in your data.&lt;/P&gt;
&lt;P&gt;I have a data source that had Primary_Care_Giver_ and Secondary_Care_Giver&amp;nbsp;followed by Last_name, First_name, Date_of_Birth, and a bunch of other characteristics.&lt;/P&gt;
&lt;P&gt;So Primary_Care_Giver_ became PCG_ and Secondary_Care_Giver&amp;nbsp;became SCG_ .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may find this code helpful in finding likely words to abbreviate. Replace YOURLIB with the uppercase name of your Library to get a list of all of the words in your labels by frequency in the proc freq output.&lt;/P&gt;
&lt;PRE&gt;Proc sql;
   create table work.labels as
   select label 
   from dictionary.columns
   where libname='YOURLIB'
   ;
run;

data work.words;
   set work.labels;
   length word $ 20;
   do i= 1 to countw(label);
      word = scan(label,i);
      output;
   end;
   drop label;
run;

Proc freq data=work.words order=freq;
   table word /nocum;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Dec 2019 19:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/better-way-to-rename-variable-names-based-on-label/m-p/612786#M178873</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-18T19:26:45Z</dc:date>
    </item>
  </channel>
</rss>

