<?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 put a list of few values inside a single variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187230#M303978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you considered using something like the following?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table WANT as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from HAVE&lt;/P&gt;&lt;P&gt;where name in (select distinct name from HAVE)&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Oct 2014 01:30:34 GMT</pubDate>
    <dc:creator>timm</dc:creator>
    <dc:date>2014-10-17T01:30:34Z</dc:date>
    <item>
      <title>How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187223#M303971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question. In my code I had a WHERE clause with IN operator and dozens of string values written inside the brackets. It wasn't very pleasant to look at, so I thought that it would be better to put these values inside a single variable and make the IN operator read them. My mainly idea was to use proc sql:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;select DISTINCT 'TABLE'n &lt;/P&gt;&lt;P&gt;into :varlist separated by '", "'&lt;/P&gt;&lt;P&gt;from USERSPDS.TABLE1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let varlist = &amp;amp;varlist;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;select DISTINCT 'LIBREF'n&lt;/P&gt;&lt;P&gt;into :var2list separated by '", "'&lt;/P&gt;&lt;P&gt;from USERSPDS.TABLE1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let var2list = &amp;amp;var2list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seemed to work fine and values I wanted to put inside these two variables are actually inside but I have problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where n1.name IN ("&amp;amp;varlist") and n1.libname IN ("&amp;amp;var2list");&amp;nbsp; &amp;lt;----&amp;nbsp; I thought that would work but I get an "error":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Val1", "Val2", "Val3", "Val4", "Val5", "Val6", "Val7", "Val8", "Val9", "Val10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&amp;nbsp;&amp;nbsp;&amp;nbsp; ____&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&lt;/P&gt;&lt;P&gt;NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.&amp;nbsp; Inserting white space between &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a quoted string and the succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That error is actually a NOTE but it stops my process.. Any idea how should I insert that white space?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 14:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187223#M303971</guid>
      <dc:creator>Dontik</dc:creator>
      <dc:date>2014-10-16T14:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187224#M303972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;TBH I don't like macro variables, so my personal preference would be to do:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp; strip(LIBNAME)||'.'||strip(NAME) in (select distinct strip(LIBNAME)||'.'||strip(NAME)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from USERSPDS.TABLE1);&lt;/P&gt;&lt;P&gt;quit; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 14:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187224#M303972</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-16T14:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187225#M303973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've done it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select DISTINCT catx("'",'TABLE'n ,"'")&lt;/P&gt;&lt;P&gt;into :varlist separated by ', '&lt;/P&gt;&lt;P&gt;from USERSPDS.TABLE1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let varlist = &amp;amp;varlist;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;select DISTINCT catx("'",'LIBREF'n,"'")&lt;/P&gt;&lt;P&gt;into :var2list separated by ', '&lt;/P&gt;&lt;P&gt;from USERSPDS.TABLE1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let var2list = &amp;amp;var2list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; where n1.name IN (&amp;amp;varlist) and n1.libname IN (&amp;amp;var2list); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 15:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187225#M303973</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2014-10-16T15:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187226#M303974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS is seeing ", " as the quoted string, which is not what you intended. You need to add a double quote character at the beginning and end of VARLIST (and VAR2LIST) so that the quoted strings are "Val1", then "Val2", etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this could be accomplished by changing the line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let varlist = &amp;amp;varlist;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let varlist = "%trim(&amp;amp;varlist)";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(and then leave out the quotes when you use the macro variables).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 16:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187226#M303974</guid>
      <dc:creator>RickAster</dc:creator>
      <dc:date>2014-10-16T16:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187227#M303975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more solution - use the quote function though I'd probably use &lt;A __default_attr="814511" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; solution instead of bothering with macro variable's at all. &lt;/P&gt;&lt;P&gt;For example can you have a data set Class in two different libraries? The first macro solution may not return exactly what you intended in that circumstances. &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 sql;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select DISTINCT quote('TABLE'n)&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;into :varlist separated by ", "&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from USERSPDS.TABLE1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let varlist = &amp;amp;varlist;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 19:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187227#M303975</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-10-16T19:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187228#M303976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey There...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used this macro many a times...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://sastechies.blogspot.com/2014/07/put-distinct-values-of-variable-in-sas.html" title="http://sastechies.blogspot.com/2014/07/put-distinct-values-of-variable-in-sas.html"&gt;SASTechies: Put distinct values of a variable in a SAS dataset to a macro variable&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 21:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187228#M303976</guid>
      <dc:creator>tanuja</dc:creator>
      <dc:date>2014-10-16T21:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187229#M303977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use QUOTE function and you don't need commas for IN operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;sql&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sashelp.class &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'Alice'&lt;/SPAN&gt; &lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'John'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;quit&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 22:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187229#M303977</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-10-16T22:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187230#M303978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you considered using something like the following?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table WANT as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from HAVE&lt;/P&gt;&lt;P&gt;where name in (select distinct name from HAVE)&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 01:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187230#M303978</guid>
      <dc:creator>timm</dc:creator>
      <dc:date>2014-10-17T01:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a list of few values inside a single variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187231#M303979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;here is how I would do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;This code would get a list of all Tables in the Data dictionary that start with "S":&amp;nbsp;&amp;nbsp; &lt;/EM&gt;NOTE: a LIST of Char variables should be quoted; a numeric list would not. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;select distinct quote(trim(memname)) into :tblList separated by "," &lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where memname like "S%: and libname eq 'MAPS'; &lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%put &amp;amp;tblList; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and this is the log for the PUT statement:&amp;nbsp;&amp;nbsp; (always a great idea to display incrementally what is be created, so put to the log liberally).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;"SALVADO2","SALVADOR","SAMERIC2","SAMERICA","SANMARI2","SANMARIN","SAUDIAR2","SAUDIARA","SERBIA"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;,"SERBIA2","SINGAPO2","SINGAPOR","SLOVAKI2","SLOVAKIA","SLOVENI2","SLOVENIA","SPACIFIC","SPAIN",&lt;/P&gt;&lt;P&gt;"SPAIN2","SRILANK2","SRILANKA","STATES","SURINAM2","SURINAME","SWEDEN","SWEDEN2","SWITZER2","SWITZERL","SYRIA","SYRIA2"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then, you can use it successfully as a FILTER in another PROC SQL step (or within the same PROC SQL and the next SELECT statement...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where n1.name IN ( &amp;amp;TBLLIST&amp;nbsp; and n1.libname IN ( &amp;amp;NEXTLIST );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NOTE: it's already quoted, so you do not need to quote the whole list again.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 14:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-list-of-few-values-inside-a-single-variable/m-p/187231#M303979</guid>
      <dc:creator>fredmayer23</dc:creator>
      <dc:date>2014-10-17T14:29:27Z</dc:date>
    </item>
  </channel>
</rss>

