<?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 make macro pass special character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924910#M364044</link>
    <description>&lt;P&gt;Sounds like you only implement HALF of the suggested fix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you set the parameter LABEL to the value of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'My Label'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;LABEL"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the code you get&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"'My Label'"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if instead the macro code just uses&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;LABEL&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then you will get&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'My Label'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the code, which is exactly what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2024 20:07:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-04-18T20:07:00Z</dc:date>
    <item>
      <title>How to make macro pass special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924727#M363979</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using a data set to create labels as guided in the Stack Overflow thread, &lt;A href="https://stackoverflow.com/questions/46407959/how-can-i-set-the-variable-labels-in-sas-using-a-table" target="_blank"&gt;https://stackoverflow.com/questions/46407959/how-can-i-set-the-variable-labels-in-sas-using-a-table&lt;/A&gt;. How should the code be modified to make it allow special characters in the labels? Thanks a lot!&lt;/P&gt;
&lt;P&gt;%macro label_it (var=, label=);&lt;BR /&gt;label &amp;amp;var. = "&amp;amp;label.";&lt;BR /&gt;%mend label_it;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select cats('%label_it(var=',var,',label=',description,')')&lt;BR /&gt;into :labellist separated by ' '&lt;BR /&gt;from varlabels;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;&amp;amp;labellist.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 16:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924727#M363979</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2024-04-17T16:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to make macro pass special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924747#M363988</link>
      <description>&lt;P&gt;That is easy.&lt;/P&gt;
&lt;P&gt;Change the macro to expect a quoted string. Then pass it a quoted string. While you are at it make it compatible with VALIDVARNAME=ANY option by using NLITERAL() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro label_it (var=, label=);
label &amp;amp;var. = &amp;amp;label.;
%mend label_it;

proc sql;
select cats('%label_it'
  ,'(var=',nliteral(var)
  ,',label=',quote(trim(description),"'")
  ,')')
  into :labellist separated by ' '
  from varlabels;
quit;

data want;
  set have;
&amp;amp;labellist.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2024 19:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924747#M363988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-17T19:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to make macro pass special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924904#M364042</link>
      <description>This works. However, there are unnecessary single quote marks in the labels.</description>
      <pubDate>Thu, 18 Apr 2024 19:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924904#M364042</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2024-04-18T19:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to make macro pass special character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924910#M364044</link>
      <description>&lt;P&gt;Sounds like you only implement HALF of the suggested fix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you set the parameter LABEL to the value of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'My Label'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;LABEL"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the code you get&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"'My Label'"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if instead the macro code just uses&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;LABEL&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then you will get&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'My Label'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the code, which is exactly what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 20:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-macro-pass-special-character/m-p/924910#M364044</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-18T20:07:00Z</dc:date>
    </item>
  </channel>
</rss>

