<?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 apply labels of  columns from other data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980517#M378950</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to add labels to colums in&amp;nbsp; data set Have.&lt;/P&gt;
&lt;P&gt;I want to use other&amp;nbsp; data set and take the labels from there instead of typing it manually.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data labels_info_tbl;
infile datalines dlm="," dsd;
length label $100 Var_name $10;
input Var_name $ label;
cards;
custID,Customer Id number
Wealth,wealth in bank in USD
education,level of education 
;
run;


data have;
/*label*/
/*custID= 'Customer Id number'*/
/*Wealth= 'wealth in bank in USD'*/
/*education= 'level of education'*/
/*;*/
input  custID Wealth education;
cards;
111 30000 15
222 7000 12 
333 350000 21
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Dec 2025 06:07:14 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-12-10T06:07:14Z</dc:date>
    <item>
      <title>apply labels of  columns from other data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980517#M378950</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to add labels to colums in&amp;nbsp; data set Have.&lt;/P&gt;
&lt;P&gt;I want to use other&amp;nbsp; data set and take the labels from there instead of typing it manually.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data labels_info_tbl;
infile datalines dlm="," dsd;
length label $100 Var_name $10;
input Var_name $ label;
cards;
custID,Customer Id number
Wealth,wealth in bank in USD
education,level of education 
;
run;


data have;
/*label*/
/*custID= 'Customer Id number'*/
/*Wealth= 'wealth in bank in USD'*/
/*education= 'level of education'*/
/*;*/
input  custID Wealth education;
cards;
111 30000 15
222 7000 12 
333 350000 21
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Dec 2025 06:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980517#M378950</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-12-10T06:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: apply labels of  columns from other data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980519#M378951</link>
      <description>&lt;P&gt;Ifound nice solution, maybe people can show other ways?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

data labels_info_tbl;
infile datalines dlm="," dsd;
length label $100 Var_name $10;
input Var_name $ label;
cards;
custID,Customer Id number
Wealth,wealth in bank in USD
education,level of education 
;
run;


data have;
/*label*/
/*custID= 'Customer Id number'*/
/*Wealth= 'wealth in bank in USD'*/
/*education= 'level of education'*/
/*;*/
input  custID Wealth education;
cards;
111 30000 15
222 7000 12 
333 350000 21
;
Run;


proc sql  noprint;
select catx('=',Var_name,quote(trim(label))) into  : label_stmt separated by ' '
from labels_info_tbl
;
quit;
%put label_stmt=&amp;amp;label_stmt;
/*label_stmt=custID="Customer Id number" Wealth="wealth in bank in USD" education="level of education"*/


proc datasets lib=work nolist;
modify have;
label &amp;amp;label_stmt;
quit;

 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Dec 2025 06:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980519#M378951</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-12-10T06:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: apply labels of  columns from other data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980522#M378952</link>
      <description>&lt;P&gt;Using CALL EXECUTE(), your macro variable's max length is 65534.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have lots of variable label, your code is unable to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data labels_info_tbl;
infile datalines dlm="," dsd;
length label $100 Var_name $10;
input Var_name $ label;
cards;
custID,Customer Id number
Wealth,wealth in bank in USD
education,level of education 
;
run;


data have;
/*label*/
/*custID= 'Customer Id number'*/
/*Wealth= 'wealth in bank in USD'*/
/*education= 'level of education'*/
/*;*/
input  custID Wealth education;
cards;
111 30000 15
222 7000 12 
333 350000 21
;
Run;

data _null_;
set labels_info_tbl end=last;
if _n_=1 then call execute('proc datasets library=work nodetails nolist;modify have;label ');
&lt;STRONG&gt;call execute(catt(var_name,"='",label,"'"));&lt;/STRONG&gt;
if last then call execute(';quit;');
run;


&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 07:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980522#M378952</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-12-10T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: apply labels of  columns from other data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980573#M378962</link>
      <description>&lt;P&gt;Sounds like you want to use DATA from another dataset, not the LABEL attached the variables in that dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converting your metadata data step into code is trivial.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set labels_info_tbl;
  length nliteral $65 ;
  nliteral=nliteral(var_name);
  file code;
  put 'label ' nliteral '=' label :$quote. ';' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use %INCLUDE to run those generated LABEL statements where ever you need them.&lt;/P&gt;
&lt;P&gt;In your data step to make the dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
%include code / source2 ;
  input  custID Wealth education;
cards;
111 30000 15
222 7000 12 
333 350000 21
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&amp;nbsp;in a PROC DATASETS step to modify the labels in an existing dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets nolist lib=work;
  modify have;
%include code / source2;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 16:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-labels-of-columns-from-other-data-set/m-p/980573#M378962</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-12-10T16:53:27Z</dc:date>
    </item>
  </channel>
</rss>

