<?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 create a macro variable into a macro function containing special characters in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483239#M31334</link>
    <description>Thanks for your help</description>
    <pubDate>Thu, 02 Aug 2018 00:47:03 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2018-08-02T00:47:03Z</dc:date>
    <item>
      <title>How to create a macro variable into a macro function containing special characters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483237#M31332</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the following code and it works.&lt;/P&gt;&lt;P&gt;But when I put it in a macro function, it failed.&lt;/P&gt;&lt;P&gt;The idea is to replace the " sign in the prolog from an xml file by %bquote(") to make sure that the macro variable has an acceptable structure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;prolog1=&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;target='"';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;replacement=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%bquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;prolog1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(tranwrd(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%quote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;prolog1.),&amp;amp;target.,&amp;amp;replacement.));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;amp;prolog1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to do the same thing but in a macro function such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;%global gtarget greplacment gprolog;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;prolog1=&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;target='"';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%let gtarget = &amp;amp;target.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;replacement=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%bquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%let greplacment= &amp;amp;replacement.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;prolog1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(tranwrd(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%quote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;prolog1.),&amp;amp;target.,&amp;amp;replacement.));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%let gprolog=&amp;amp;prolog1.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%mend test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%put &amp;amp;gprolog.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%put &amp;amp;greplacement.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%put &amp;amp;gtarget.;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 23:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483237#M31332</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-08-01T23:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable into a macro function containing special characters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483238#M31333</link>
      <description>&lt;P&gt;Corrected:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;

%global gtarget greplacement gprolog;

 

%let prolog1=&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;;

%let target='"';

%let gtarget = &amp;amp;target.;

%let replacement=%str(%");

%let greplacement=( &amp;amp;replacement.);

%let prolog1=%sysfunc(tranwrd(%quote(&amp;amp;prolog1.),&amp;amp;target.,( &amp;amp;replacement.)));

%let gprolog=&amp;amp;prolog1.;

 

%mend test;

%test;


%put &amp;amp;gprolog.;

%put &amp;amp;greplacement.;

%put &amp;amp;gtarget.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 00:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483238#M31333</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-02T00:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable into a macro function containing special characters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483239#M31334</link>
      <description>Thanks for your help</description>
      <pubDate>Thu, 02 Aug 2018 00:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483239#M31334</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-08-02T00:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable into a macro function containing special characters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483246#M31335</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I have tried the following code and it works.&lt;/P&gt;
&lt;P&gt;But when I put it in a macro function, it failed.&lt;/P&gt;
&lt;P&gt;The idea is to replace the " sign in the prolog from an xml file by %bquote(") to make sure that the macro variable has an acceptable structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That will not actual apply macro quoting to the quotes, since the use of %SYSFUNC() instead of %QSYSFUNC() will remove the macro quoting.&lt;/P&gt;
&lt;P&gt;If you just want to quote the special characters in the input then use a regular macro quoting function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prolog3=%superq(prolog1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see it this picture the value of PROLOG3 has macro quoting and the value of PROLOG1 and PROLOG2 don't.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22159i1A4622E241EEA2B1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 02:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-macro-variable-into-a-macro-function-containing/m-p/483246#M31335</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-02T02:17:24Z</dc:date>
    </item>
  </channel>
</rss>

