<?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 Add quotation marks to string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302778#M64266</link>
    <description>&lt;P&gt;Let's say I have macro variable &amp;amp;mvar that has a list of values in it (aaaaa bbbbb ccccc ... zzzzz). I need to surround each of these values with quotation marks so that I can use them later in my program as a list of possible character variable values (i.e., "if var1 in (&amp;amp;mvar) then &lt;EM&gt;X&lt;/EM&gt;"). Is there a way to do this programatically, or am I stuck doing it by hand? (Using SAS Enterprise Guide 7.11)&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 20:02:30 GMT</pubDate>
    <dc:creator>scify</dc:creator>
    <dc:date>2016-10-05T20:02:30Z</dc:date>
    <item>
      <title>Add quotation marks to string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302778#M64266</link>
      <description>&lt;P&gt;Let's say I have macro variable &amp;amp;mvar that has a list of values in it (aaaaa bbbbb ccccc ... zzzzz). I need to surround each of these values with quotation marks so that I can use them later in my program as a list of possible character variable values (i.e., "if var1 in (&amp;amp;mvar) then &lt;EM&gt;X&lt;/EM&gt;"). Is there a way to do this programatically, or am I stuck doing it by hand? (Using SAS Enterprise Guide 7.11)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 20:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302778#M64266</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2016-10-05T20:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add quotation marks to string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302781#M64268</link>
      <description>&lt;P&gt;You're in luck.&amp;nbsp; Someone else asked the same question earlier today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Adding-Single-Quote-to-list-of-strings/m-p/302599" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Adding-Single-Quote-to-list-of-strings/m-p/302599&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, you don't have to necessarily break out the strings individually.&amp;nbsp; You could also use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(" &amp;amp;mvar ", ' ' || strip(var1) || ' ') then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need the leading and trailing blanks to make the comparison produce the right result.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 20:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302781#M64268</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T20:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Add quotation marks to string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302814#M64281</link>
      <description>&lt;P&gt;To create the macro variable with quotes in the same place than the macro variable with blanks is likely the "best" approach but shouldn't this be possible for some reason then below code will&amp;nbsp;do the job as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=aaaaa bbbbb ccccc zzzzz;

%let mvar_quotes=%nrbquote(')%qsysfunc(prxchange(s/\s+/%nrbquote(',')/oi,-1,&amp;amp;mvar))%nrbquote(');

%put mvar_quotes: %bquote(&amp;amp;mvar_quotes);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS Log:&lt;/P&gt;
&lt;P&gt;mvar_quotes: 'aaaaa','bbbbb','ccccc','zzzzz'&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 23:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302814#M64281</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-05T23:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Add quotation marks to string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302822#M64284</link>
      <description>&lt;PRE&gt;
Or maybe you don't need add quote around them, use SYMGET() instead.

%let list=F M;
data x;
 set sashelp.class;
 if findw(symget('list'),strip(sex));
run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2016 02:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-quotation-marks-to-string/m-p/302822#M64284</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-06T02:29:23Z</dc:date>
    </item>
  </channel>
</rss>

