<?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 Mask special character in macro value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452385#M283919</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looping through unique values of a variable that I use to create charts using call symput. But some of the values contain special characters like apostrophe and that's where I run into issues. How do I tell SAS to mask any special characters stored in my macro value? Below is my sample code (and the red text is where i get into trouble when the custname value is, for example, "CUST'A":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set topcust1;
call symput('custname'||left(_n_),strip(custname));
call symput('stop',left(_n_));
run;


/*CREATE CHARTS*/

%macro createplots;
%do i=1 %to 10;&lt;FONT color="#FF0000"&gt;title1 J=C font="&amp;amp;font/bold" H=13pt "PRICE CHART BY CUSTOMER: %upcase(&amp;amp;&amp;amp;custname&amp;amp;i.))";&lt;/FONT&gt;


proc gplot data=data1 (where=(custname="&amp;amp;&amp;amp;custname&amp;amp;i."));
plot price*date = group/ 
skipmiss
haxis=axis1 
vaxis=axis2 
run;quit;
%end;
%mend;



ods _all_ close; 
ods listing; 
ods pdf file="&amp;amp;outpath\&amp;amp;file.";
%createplots;
ods pdf close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 08 Apr 2018 23:56:37 GMT</pubDate>
    <dc:creator>dl0324</dc:creator>
    <dc:date>2018-04-08T23:56:37Z</dc:date>
    <item>
      <title>Mask special character in macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452385#M283919</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looping through unique values of a variable that I use to create charts using call symput. But some of the values contain special characters like apostrophe and that's where I run into issues. How do I tell SAS to mask any special characters stored in my macro value? Below is my sample code (and the red text is where i get into trouble when the custname value is, for example, "CUST'A":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set topcust1;
call symput('custname'||left(_n_),strip(custname));
call symput('stop',left(_n_));
run;


/*CREATE CHARTS*/

%macro createplots;
%do i=1 %to 10;&lt;FONT color="#FF0000"&gt;title1 J=C font="&amp;amp;font/bold" H=13pt "PRICE CHART BY CUSTOMER: %upcase(&amp;amp;&amp;amp;custname&amp;amp;i.))";&lt;/FONT&gt;


proc gplot data=data1 (where=(custname="&amp;amp;&amp;amp;custname&amp;amp;i."));
plot price*date = group/ 
skipmiss
haxis=axis1 
vaxis=axis2 
run;quit;
%end;
%mend;



ods _all_ close; 
ods listing; 
ods pdf file="&amp;amp;outpath\&amp;amp;file.";
%createplots;
ods pdf close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 23:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452385#M283919</guid>
      <dc:creator>dl0324</dc:creator>
      <dc:date>2018-04-08T23:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Mask special character in macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452386#M283920</link>
      <description>&lt;P&gt;Use %bquote function to mask the resolved macro var value&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 00:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452386#M283920</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-09T00:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Mask special character in macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452387#M283921</link>
      <description>&lt;P&gt;Here is one way&amp;nbsp;that&amp;nbsp;the data step which generates the macro variables can immediately re-create them with macro quoting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if eof then call symputx('stop',_n_-1);
  set topcust1 end=eof;
  mvar=cats('custname',_n_);
  call symputx(mvar,custname);
  call execute(catx(' ','%let',mvar,'=%superq(',mvar,');'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although in your situation why not just add real quotes?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if eof then call symputx('stop',_n_-1);
  set topcust1 end=eof;
  call symputx(cats('custname',_n_),quote(trim(custname),"'"));
run;
...
(where=(custname=&amp;amp;&amp;amp;custname&amp;amp;i))
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2018 00:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-special-character-in-macro-value/m-p/452387#M283921</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-09T00:16:32Z</dc:date>
    </item>
  </channel>
</rss>

