<?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 Convert all column labels to column name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546622#M151369</link>
    <description>&lt;P&gt;I am using PROC SQL to develop tables for use in SAS Visual Analytics (v7.4). However, I spend time modifying column names in SQL with the AS keyword, but this changes only the name, and not the label that gets added by default, and SAS VA displays column labels, not names, and as far as I can tell, there is no option for VA to display names, not labels.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody provide a programmatic solution to converting all of the column labels in a table to the name for that column? Is there an option in PROC SQL, or perhaps a statement in the DATA step that might solve this problem? Or should I go about writing a macro to loop through the column names?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this, and it doesn't work, providing an error: "Expecting an =."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

select 	name
into 	:colnames separated by ' '
from 	dictionary.columns
where 	libname='SASHELP' 
	and	memname='CARS'
;
quit;

data cars_w_labs;
set SASHELP.CARS;

do i=1 to countw("&amp;amp;colnames");

label scan("&amp;amp;colnames", i) = scan("&amp;amp;colnames", i);

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 18:43:12 GMT</pubDate>
    <dc:creator>tfarkas</dc:creator>
    <dc:date>2019-03-27T18:43:12Z</dc:date>
    <item>
      <title>Convert all column labels to column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546622#M151369</link>
      <description>&lt;P&gt;I am using PROC SQL to develop tables for use in SAS Visual Analytics (v7.4). However, I spend time modifying column names in SQL with the AS keyword, but this changes only the name, and not the label that gets added by default, and SAS VA displays column labels, not names, and as far as I can tell, there is no option for VA to display names, not labels.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody provide a programmatic solution to converting all of the column labels in a table to the name for that column? Is there an option in PROC SQL, or perhaps a statement in the DATA step that might solve this problem? Or should I go about writing a macro to loop through the column names?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this, and it doesn't work, providing an error: "Expecting an =."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

select 	name
into 	:colnames separated by ' '
from 	dictionary.columns
where 	libname='SASHELP' 
	and	memname='CARS'
;
quit;

data cars_w_labs;
set SASHELP.CARS;

do i=1 to countw("&amp;amp;colnames");

label scan("&amp;amp;colnames", i) = scan("&amp;amp;colnames", i);

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 18:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546622#M151369</guid>
      <dc:creator>tfarkas</dc:creator>
      <dc:date>2019-03-27T18:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all column labels to column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546632#M151374</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars;
set sashelp.cars;
run;

data _null_;
set sashelp.vtable (where=(libname='WORK' and memname = 'CARS')) end=eof;
if _n_ = 1 then call execute("
  proc datasets library=work;
  modify cars;
  label 
");
call execute(strip(name) !! '="' !! strip(name) !! '" ');
if eof then call execute('; quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 18:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546632#M151374</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-27T18:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all column labels to column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546647#M151381</link>
      <description>&lt;P&gt;You can assign attributes such as label and format to variables when created in Proc SQL&lt;/P&gt;
&lt;PRE&gt;data have;
   x=23;
run;

proc sql;
   select (2* x) as xx label='Some label' format=z4.
   from have
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;or suppress the label&lt;/P&gt;
&lt;PRE&gt;data have;
   x=23;
   label x='Some longer label'
run;

proc sql;
   select  x  label='' 
   from have
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 19:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546647#M151381</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-27T19:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all column labels to column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546649#M151383</link>
      <description>&lt;P&gt;Pretty sure if you remove all labels it defaults to column names instead. You can remove all labels from your&amp;nbsp; variables using the following code. Note that this does not regenerate your data sets, it modifies the metadata in place, so will be quite fast, as will other PROC DATASETS solutions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets library=mylib nolist;
  modify mydataset;
  attrib _all_ label='';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238489"&gt;@tfarkas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using PROC SQL to develop tables for use in SAS Visual Analytics (v7.4). However, I spend time modifying column names in SQL with the AS keyword, but this changes only the name, and not the label that gets added by default, and SAS VA displays column labels, not names, and as far as I can tell, there is no option for VA to display names, not labels.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can somebody provide a programmatic solution to converting all of the column labels in a table to the name for that column? Is there an option in PROC SQL, or perhaps a statement in the DATA step that might solve this problem? Or should I go about writing a macro to loop through the column names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried this, and it doesn't work, providing an error: "Expecting an =."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

select 	name
into 	:colnames separated by ' '
from 	dictionary.columns
where 	libname='SASHELP' 
	and	memname='CARS'
;
quit;

data cars_w_labs;
set SASHELP.CARS;

do i=1 to countw("&amp;amp;colnames");

label scan("&amp;amp;colnames", i) = scan("&amp;amp;colnames", i);

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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>Wed, 27 Mar 2019 19:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546649#M151383</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-27T19:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all column labels to column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546874#M151491</link>
      <description>&lt;P&gt;Try option :&lt;/P&gt;
&lt;PRE&gt;options nolabel ;&lt;/PRE&gt;
&lt;P&gt;Or try Reeza 's proc datasets code .&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 12:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-all-column-labels-to-column-name/m-p/546874#M151491</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-28T12:38:00Z</dc:date>
    </item>
  </channel>
</rss>

