<?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 Tranwrd a single quotation mark in Macro Var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554286#M154187</link>
    <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Struggling with an issue to add a single quote symbol into a macro var by function twanwrd and add it to a label of a variable.&lt;/P&gt;&lt;P&gt;The idea, that I want to have a label of a var as "Smith' car". At the moment I have a macro var "SmithZZZ car".&lt;/P&gt;&lt;P&gt;This is the code I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let have=SmithZZZ car;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var1="have";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var2="want";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;label var1="&amp;amp;have";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%let want=%sysfunc(tranwrd(%bquote(&amp;amp;have),%str(ZZZ),%str(%')));&lt;BR /&gt;&amp;nbsp; &amp;nbsp;label var2="&amp;amp;want";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this code does not work,&amp;nbsp; and I tried many ways to solve the issue, but without success.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone propose a solution?&lt;/P&gt;</description>
    <pubDate>Fri, 26 Apr 2019 14:27:32 GMT</pubDate>
    <dc:creator>sburnos</dc:creator>
    <dc:date>2019-04-26T14:27:32Z</dc:date>
    <item>
      <title>Tranwrd a single quotation mark in Macro Var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554286#M154187</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Struggling with an issue to add a single quote symbol into a macro var by function twanwrd and add it to a label of a variable.&lt;/P&gt;&lt;P&gt;The idea, that I want to have a label of a var as "Smith' car". At the moment I have a macro var "SmithZZZ car".&lt;/P&gt;&lt;P&gt;This is the code I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let have=SmithZZZ car;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var1="have";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var2="want";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;label var1="&amp;amp;have";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%let want=%sysfunc(tranwrd(%bquote(&amp;amp;have),%str(ZZZ),%str(%')));&lt;BR /&gt;&amp;nbsp; &amp;nbsp;label var2="&amp;amp;want";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this code does not work,&amp;nbsp; and I tried many ways to solve the issue, but without success.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone propose a solution?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554286#M154187</guid>
      <dc:creator>sburnos</dc:creator>
      <dc:date>2019-04-26T14:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Tranwrd a single quotation mark in Macro Var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554291#M154189</link>
      <description>&lt;P&gt;So, I can't see any purpose for your data step. The following ought to work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let have=SmithZZZ car;
%put &amp;amp;=have;

%let want=%qsysfunc(tranwrd(&amp;amp;have,ZZZ,%str(%')));
%put &amp;amp;=want;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or even simpler, without macro variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    have='SmithZZZ car';
    want=tranwrd(have,'ZZZ',"'");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554291#M154189</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-26T14:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Tranwrd a single quotation mark in Macro Var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554300#M154193</link>
      <description>&lt;P&gt;Thank you a lot. Have spent a day on searching for a solution. You replied within 10 minutes.&lt;/P&gt;&lt;P&gt;For the future will use the help of SAS community more frequently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding data step, my ultimate goal was to assign the value of macro variable to a label. Therefore I needed that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554300#M154193</guid>
      <dc:creator>sburnos</dc:creator>
      <dc:date>2019-04-26T14:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Tranwrd a single quotation mark in Macro Var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554315#M154197</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let have=SmithZZZ car;
%let want=%bquote(%sysfunc(prxchange(s/Z+\b/%str(%')/i,1,&amp;amp;have)));

%put &amp;amp;have;
%put &amp;amp;want;

title "&amp;amp;want";
proc print data=sashelp.class;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2019 15:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tranwrd-a-single-quotation-mark-in-Macro-Var/m-p/554315#M154197</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-26T15:12:58Z</dc:date>
    </item>
  </channel>
</rss>

