<?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: Quote and Unquote a list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205514#M38206</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two things to try.&lt;/P&gt;&lt;P&gt;1) Using the QUOTE() function to add quotes when the strings include quotes.&lt;/P&gt;&lt;P&gt;TITLE %sysfunc(quote(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Data for &amp;amp;name_quoted)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;2) Use the CATQ() function to add quotes when strings do not include quotes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%let list=a b ;&lt;/P&gt;&lt;P&gt;%put %sysfunc(catq('1a',%sysfunc(translate(&amp;amp;list,%str(,),%str( )))));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2015 14:31:16 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-04-28T14:31:16Z</dc:date>
    <item>
      <title>Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205512#M38204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I'm using SAS9.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is anyone aware of a macro statement to remove quotes from a list, so that the same list could be used for multiple purposes?&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Example below where a list requires a quoted and unquoted version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Using two macros - this is what I am trying to avoid. */&lt;/P&gt;&lt;P&gt;%let name_quoted='Mary' 'Philip'; &lt;/P&gt;&lt;P&gt;%let name_unquoted =Mary Philip;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc report data=sashelp.class;&lt;/P&gt;&lt;P&gt;title1 "Data for &amp;amp;name_unquoted.";&amp;nbsp;&amp;nbsp; /* list without quotes */&lt;/P&gt;&lt;P&gt;where name in (&amp;amp;name_quoted);&amp;nbsp;&amp;nbsp; /* list requires quotes */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All ideas are welcomed, however I was thinking there was a macro function that might work for this scenario?&lt;/P&gt;&lt;P&gt;RB1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 13:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205512#M38204</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-04-28T13:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205513#M38205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Personally I have been using a utility macro to add the quotes when needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let list&lt;SPAN style="line-height: 1.5em;"&gt; =Mary Philip;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; proc report data=sashelp.class;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;title1 "Data for &amp;amp;list.";&amp;nbsp;&amp;nbsp; /* list without quotes */&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where name in %qlist(&amp;amp;list);&amp;nbsp;&amp;nbsp; /* list requires quotes */&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205513#M38205</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-04-28T14:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205514#M38206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two things to try.&lt;/P&gt;&lt;P&gt;1) Using the QUOTE() function to add quotes when the strings include quotes.&lt;/P&gt;&lt;P&gt;TITLE %sysfunc(quote(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Data for &amp;amp;name_quoted)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;2) Use the CATQ() function to add quotes when strings do not include quotes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%let list=a b ;&lt;/P&gt;&lt;P&gt;%put %sysfunc(catq('1a',%sysfunc(translate(&amp;amp;list,%str(,),%str( )))));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205514#M38206</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-04-28T14:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205515#M38207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom&lt;/P&gt;&lt;P&gt;I had to google "utility macro" and I've just glanced at this paper (&lt;A href="http://www2.sas.com/proceedings/sugi30/029-30.pdf" title="http://www2.sas.com/proceedings/sugi30/029-30.pdf"&gt;http://www2.sas.com/proceedings/sugi30/029-30.pdf&lt;/A&gt;).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran your example above but %Qlist was not recognized. So, is your macro &lt;STRONG&gt;%qlist&lt;/STRONG&gt; something you've created as an autocall macro (could I see that code please?), or is it something that is there in the installation but not mapped on my machine?&lt;/P&gt;&lt;P&gt;I tend to use enterprise guide by the way, version 5.1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205515#M38207</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-04-28T14:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205516#M38208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, my first question would be why.&amp;nbsp; Your example doesn't really give any information about what this method would add to a process. For more complicated use of lists I always recommend storing in a dataset, which can be manipulated using base SAS techniques.&amp;nbsp; With this type of macro variables code gets complicated and unreadble very quickly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205516#M38208</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-28T14:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205517#M38209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fair question RW9!&amp;nbsp; I had thought of putting lists into a dataset but I had a nagging feeling that there might be a function to do the task that I wasn't aware of.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205517#M38209</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-04-28T14:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205518#M38210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a simplified version without parameter checking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%macro qlist(list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;(%unquote(%str(%')%sysfunc(tranwrd(&amp;amp;list,%str( ),','))%str(%')))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%mend qlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 15:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205518#M38210</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-04-28T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205519#M38211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom, That's exactly what I was looking for!&lt;/P&gt;&lt;P&gt;Rb1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 07:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205519#M38211</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-04-29T07:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205520#M38212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let name_unquoted =Mary Philip;&lt;/P&gt;&lt;P&gt;%let name_quoted= %sysfunc(prxchange(s/(\w+)\s+(\w+)/"\1" "\2"/,-1,&amp;amp;name_unquoted));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put&amp;nbsp; &amp;amp;name_quoted;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Mary" "Philip"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you don't need to transform it . use symget() instead .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc report data=sashelp.class;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;title1 "Data for &amp;amp;name_unquoted.";&amp;nbsp;&amp;nbsp; /* list without quotes */&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;where symget ("&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;name_unquoted&lt;/SPAN&gt;")&amp;nbsp; contains strip(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;name)&amp;nbsp; &lt;/SPAN&gt; ;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; /* list requires quotes */&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 12:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205520#M38212</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-29T12:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205521#M38213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xia, that's two very interesting solutions.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 12:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205521#M38213</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-04-29T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205522#M38214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Be aware that using a list in a macro variable (e.g. %let mvar= A B C D) has a character limit which will cause an error message to occur.&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="34126" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 09:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/205522#M38214</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2015-05-21T09:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/250620#M47266</link>
      <description>&lt;P&gt;I have a similar problem. I have several dates (see longer proc sql statements) that I'd like to put in a string so that I don't need to enter them twice. The hardcoded dates work (longer code, at bottom), but the code at the top does not. I can't figure out how to quote them in SAS. Thanks for any/all help.&lt;/P&gt;
&lt;PRE&gt;%let site = KBOS;
%let dateStr = '18Dec2015'd ;
options symbolgen;
proc sql;
	select * from mylib.analysisStatus
		where		site = "&amp;amp;site" AND date in quote(&amp;amp;dateStr) 
			order by date;
quit;


proc sql;
	update mylib.analysisStatus
		set analysisStatus = 6
			where		site = "&amp;amp;site" and date in ('18Dec2015'd, '24Jan2016'd, '23Jan2016'd );
	select * from mylib.analysisStatus
		where		site = "&amp;amp;site" AND date in ('18Dec2015'd, '24Jan2016'd, '23Jan2016'd ) 
			order by date;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Feb 2016 14:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/250620#M47266</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2016-02-17T14:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Quote and Unquote a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/274561#M54821</link>
      <description>&lt;P&gt;This worked to me!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 08:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-and-Unquote-a-list/m-p/274561#M54821</guid>
      <dc:creator>invisibleman</dc:creator>
      <dc:date>2016-06-02T08:19:26Z</dc:date>
    </item>
  </channel>
</rss>

