<?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: How to automatically rename variable names using their labels? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880301#M347816</link>
    <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n17dcq1elcvpvkn1pkecj41cva6j.htm" target="_blank" rel="noopener"&gt;PROC PRINT Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jun 2023 21:08:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-06-12T21:08:54Z</dc:date>
    <item>
      <title>How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880288#M347807</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Before exporting the SAS data set to Excel file, I tried to&amp;nbsp;rename their variable names by using variable's labels.&lt;/P&gt;&lt;P&gt;Some of variable labels have spaces between the words.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to automatically rename variable names using their labels with filling a underscore (e.g. '_') if there is a space between the words of the label?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need help with SAS coding.&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, 12 Jun 2023 20:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880288#M347807</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2023-06-12T20:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880290#M347809</link>
      <description>Do you really want underscores in Excel? you can have spaces in the name if the only purpose is to export, however you're still limited to 32 characters. &lt;BR /&gt;&lt;BR /&gt;Note that depending on how you export to Excel you can also just have the labels show instead of the variable names.</description>
      <pubDate>Mon, 12 Jun 2023 20:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880290#M347809</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-12T20:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880291#M347810</link>
      <description>&lt;P&gt;Why?&lt;/P&gt;
&lt;P&gt;Variable labels can be over 200 characters long, variable names are limited to 32 characters. Are you really trying to stuff 10 pounds of stuff into a 5 pound bag?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 20:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880291#M347810</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-12T20:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880294#M347812</link>
      <description>&lt;P&gt;My variable labels are sort of dictionary of variable names even filling with a underscore between the words.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 20:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880294#M347812</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2023-06-12T20:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880297#M347813</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
    set sashelp.class;
    label name="NAme" sex="GEndeR" age="Age in years" height="HeiGht in inches" weight="weight in lbs";
run;

proc sql noprint;
    select catx('=', name, transtrn(lowcase(trim(label)), " ", "_")) 
        into :rename_list separated by " " from sashelp.vcolumn where libname='WORK' 
        and upper(memname)='CLASS';
quit;

%put &amp;amp;rename_list;


proc datasets lib=work nodetails nolist;
    modify class;
    rename &amp;amp;rename_list;
    run;
quit;

proc print data=class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2023 20:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880297#M347813</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-12T20:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880298#M347814</link>
      <description>Again, why not just run ODS EXCEL and proc print with labels to the excel file?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2023 20:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880298#M347814</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-12T20:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880300#M347815</link>
      <description>&lt;P&gt;I'll definitely give a try.&amp;nbsp; Do you have any example to share?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your prompt helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 21:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880300#M347815</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2023-06-12T21:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880301#M347816</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n17dcq1elcvpvkn1pkecj41cva6j.htm" target="_blank" rel="noopener"&gt;PROC PRINT Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 21:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880301#M347816</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-12T21:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880302#M347817</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data class;
    set sashelp.class;
    label name="NAme" sex="GEndeR" age="Age in years" height="HeiGht in inches" weight="weight in lbs";
run;

ods excel file='/home/fkhurshed/demo.xlsx';

proc print data=class label noobs;
run;

ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/23924"&gt;@t75wez1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'll definitely give a try.&amp;nbsp; Do you have any example to share?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your prompt helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 21:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880302#M347817</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-12T21:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880307#M347822</link>
      <description>&lt;P&gt;Thanks for your ODS solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If exporting it to Excel, i have a control to give a tab name(see below). How to give a customized tab name in ODS Excel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC EXPORT DATA= tmp_view OUTFILE= "&amp;amp;outputname." DBMS=xlsx REPLACE;&lt;BR /&gt;SHEET="&amp;amp;tabname.";&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 21:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880307#M347822</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2023-06-12T21:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880310#M347824</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
    set sashelp.class;
    label name="NAme" sex="GEndeR" age="Age in years" height="HeiGht in inches" weight="weight in lbs";
run;

ods excel file='/home/fkhurshed/demo.xlsx' options(sheet_name = "example name");

proc print data=class label noobs;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ODS EXCEL usage&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 22:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/880310#M347824</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-12T22:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically rename variable names using their labels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/881229#M348188</link>
      <description>&lt;P&gt;Thanks for your helps again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 22:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-rename-variable-names-using-their-labels/m-p/881229#M348188</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2023-06-16T22:05:01Z</dc:date>
    </item>
  </channel>
</rss>

