<?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: get label of a macro variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197734#M49420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is possible to write some macro code using SAS data set access function or depending on the version of SAS you are using DOSUBL.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The details of your macro %INC_CVT will also play a role in how it can be implemented.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Mar 2015 20:02:38 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2015-03-09T20:02:38Z</dc:date>
    <item>
      <title>get label of a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197731#M49417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am transforming some variables and want to keep their labels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I took 3 months lags on each variable of interest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;proc expand data=in_a&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; out=out_b&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; method = none&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: black;"&gt;id time&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM style="color: #999900;"&gt;%inn_cvt&lt;/EM&gt;&lt;SPAN style="color: black;"&gt;(innvar3=&lt;/SPAN&gt;&lt;SPAN style="color: navy;"&gt;&amp;amp;&amp;amp;inxvar&amp;amp;inn_i3.&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;., innlg=3)&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where &lt;SPAN style="color: navy;"&gt;&amp;amp;&amp;amp;inxvar&amp;amp;inn_i3.&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;. loop through a bunch of variables. After this transformation, I want to keep the label of pre-transform variable, but edit label for after-transform variable as " pre-transform variable label + Lag 3"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do it?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 18:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197731#M49417</guid>
      <dc:creator>Sunny_Sun</dc:creator>
      <dc:date>2015-03-09T18:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: get label of a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197732#M49418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might want to use the VLabel function prior to the current step you are working with to add the labels of the desired variables.&lt;/P&gt;&lt;P&gt;Another approach would be to collect the information about the variables in your input data set before the step and then use the information after the expand to modify the labels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table variableinformation as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where member='IN_A' and libname='WORK';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the data in the resulting data set variableinformation to create the new labels and assign via proc datasets would be on way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 19:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197732#M49418</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-09T19:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: get label of a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197733#M49419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this might do the trick:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib var1 label = 'Label of var 1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2 label = 'Label of var 2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var3 label = 'Label of var 3';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2 = 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var3 = 3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data = test1 out = contents_test1 (keep = name label) ; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data contents_test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set contents_test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length labelname $100; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; labelname = 'label_'||strip(name);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set contents_test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx(labelname, label);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro do_stuff(innlg= );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put i = &amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put varname for &amp;amp;i -&amp;gt; &amp;amp;&amp;amp;varname&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* get label using varname */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put label for &amp;amp;&amp;amp;varname&amp;amp;i -&amp;gt; &amp;amp;&amp;amp;&amp;amp;&amp;amp;label_&amp;amp;&amp;amp;varname&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let new_label = Pre-transform &amp;amp;&amp;amp;&amp;amp;&amp;amp;label_&amp;amp;&amp;amp;varname&amp;amp;i + &amp;amp;innlg;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put new label = &amp;amp;new_label;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%do_stuff(innlg = 3);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 19:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197733#M49419</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2015-03-09T19:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: get label of a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197734#M49420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is possible to write some macro code using SAS data set access function or depending on the version of SAS you are using DOSUBL.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The details of your macro %INC_CVT will also play a role in how it can be implemented.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 20:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/get-label-of-a-macro-variable/m-p/197734#M49420</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-09T20:02:38Z</dc:date>
    </item>
  </channel>
</rss>

