<?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 how to get a variable label in to a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602781#M174559</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help on how to get a variable label name in to macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input age Ageu $;
datalines;
12 Y
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose the age variable label is '&lt;FONT color="#FF6600"&gt;age in years&lt;/FONT&gt;'. I need to create a macro variable with label value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let want=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed;&lt;/P&gt;
&lt;P&gt;want='age in years'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Nov 2019 17:13:29 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2019-11-08T17:13:29Z</dc:date>
    <item>
      <title>how to get a variable label in to a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602781#M174559</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help on how to get a variable label name in to macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input age Ageu $;
datalines;
12 Y
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose the age variable label is '&lt;FONT color="#FF6600"&gt;age in years&lt;/FONT&gt;'. I need to create a macro variable with label value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let want=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed;&lt;/P&gt;
&lt;P&gt;want='age in years'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 17:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602781#M174559</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2019-11-08T17:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a variable label in to a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602790#M174561</link>
      <description>&lt;P&gt;So where are we suppose to "get" the variable label from? The data set you create has no label assigned so there isn't any place to get the label from.&lt;/P&gt;
&lt;P&gt;If you SET from a data set that has an assigned label you can use the vlabel function in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x=3;
   label x ='Some label';
run;

data _null_;
   set example (obs=1);
   labeltext= vlabel(x);
   call symputx('xlabel',labeltext);
run;

%put label for x is: &amp;amp;xlabel.;
&lt;/PRE&gt;
&lt;P&gt;Or extract the value from sashelp.vcolumn view&amp;nbsp;&amp;nbsp;or the Dictionary.columns table in Proc SQL using :INTO&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 17:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602790#M174561</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-08T17:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a variable label in to a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602791#M174562</link>
      <description>&lt;P&gt;Try the VARLABEL Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n15lqt6a2pdg1in1w295ql8wel1a.htm&amp;amp;docsetVersion=1.0&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n15lqt6a2pdg1in1w295ql8wel1a.htm&amp;amp;docsetVersion=1.0&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 17:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602791#M174562</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-11-08T17:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a variable label in to a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602793#M174563</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
 input age Ageu $;
 attrib age label="Age in Years";
 datalines;
12 Y
;

proc print data = one label;

data _NULL_;
 set one;
 file print;
 length lab $50.;
 call label (age, lab);
 call symput ('want', lab);
 put lab = ;
run;

%put &amp;amp;want;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 17:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602793#M174563</guid>
      <dc:creator>chaatak</dc:creator>
      <dc:date>2019-11-08T17:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a variable label in to a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602810#M174570</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20640"&gt;@chaatak&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good advice, but I would tweak your program just a little.&amp;nbsp; If the only goal is to retrieve and report the label of a variable, then there is no need to read every observation (or any observation at all) from data set ONE.&amp;nbsp; After all, if ONE had one million observations, there is no need to issue the CALL label and CALL symput 1mm times.&amp;nbsp; Yes, in your sample dataset, this not a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as a defensive measure you could just change the "set one:"&amp;nbsp; statement to:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set one (obs=1);&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did say you don't even have to read one observation, because another option is:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;if 0 then set one;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this task, it won't be any more efficient than the "(obs=1)" approach, but it's a good device for reminder yourself that this data step is about meta-data, not data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 19:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-a-variable-label-in-to-a-macro-variable/m-p/602810#M174570</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-08T19:00:37Z</dc:date>
    </item>
  </channel>
</rss>

