<?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 How to add double quotes to string in open code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513350#M138308</link>
    <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp;I have a fairly simple question. When I have a string in open code, how can I add single / double quotes around it ?&amp;nbsp;&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;%Let sep = %str(-);
%Let first = %str(uday) ; 
%Let last = %str(guntupalli);
%Let name = %sysfunc(catx(&amp;amp;sep.,&amp;amp;first.,&amp;amp;last.));  
%Put &amp;amp;name.; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I looked at discussions in the community but they use a data step. Can anybody kindly show, how I can achieve similar results in open code ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&amp;nbsp;&lt;BR /&gt;Uday&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Nov 2018 15:11:17 GMT</pubDate>
    <dc:creator>UdayGuntupalli</dc:creator>
    <dc:date>2018-11-15T15:11:17Z</dc:date>
    <item>
      <title>How to add double quotes to string in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513350#M138308</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp;I have a fairly simple question. When I have a string in open code, how can I add single / double quotes around it ?&amp;nbsp;&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;%Let sep = %str(-);
%Let first = %str(uday) ; 
%Let last = %str(guntupalli);
%Let name = %sysfunc(catx(&amp;amp;sep.,&amp;amp;first.,&amp;amp;last.));  
%Put &amp;amp;name.; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I looked at discussions in the community but they use a data step. Can anybody kindly show, how I can achieve similar results in open code ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&amp;nbsp;&lt;BR /&gt;Uday&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 15:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513350#M138308</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-11-15T15:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add double quotes to string in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513359#M138313</link>
      <description>&lt;P&gt;You could use add the double quotes.&amp;nbsp; Single quotes are a little harder since macro references inside of them will not resolve.&lt;/P&gt;
&lt;P&gt;Or you could use the QUOTE() function.&amp;nbsp; That will also take care to double up any embedded quotes for you.&lt;/P&gt;
&lt;PRE&gt;122  %put &amp;amp;first.&amp;amp;sep.&amp;amp;last ;
uday-guntupalli
123  %put "&amp;amp;first.&amp;amp;sep.&amp;amp;last";
"uday-guntupalli"
124  %put %str(%')&amp;amp;first.&amp;amp;sep.&amp;amp;last%str(%');
'uday-guntupalli'
125  %put %sysfunc(quote(&amp;amp;first.&amp;amp;sep.&amp;amp;last));
"uday-guntupalli"
126  %put %sysfunc(quote(&amp;amp;first.&amp;amp;sep.&amp;amp;last,%str(%')));
'uday-guntupalli'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you do need to add single quotes a lot (for example for pass thru SQL or strings with embedded &amp;amp; or % characters) then you might want to use a utility macro like:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/squote.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/squote.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 15:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513359#M138313</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-15T15:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to add double quotes to string in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513366#M138316</link>
      <description>&lt;P&gt;Its very rarely, if ever, a good idea to put quotes in macro variables.&amp;nbsp; Just look at the trouble to do something simple like put a double quote in, its really more effort than its worth.&amp;nbsp; Macro should note replace datastep, base SAS is the programming language, use that and you will not have all this messy code.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 15:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-double-quotes-to-string-in-open-code/m-p/513366#M138316</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-15T15:26:36Z</dc:date>
    </item>
  </channel>
</rss>

