<?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: create a item list and use for entire code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470905#M120546</link>
    <description>&lt;P&gt;The key thing to remember is that this is direct text replacement. So following that logic, your code becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fruitlist = apple, orange, banana;

select *
from table A
where fruit in (apple, orange, banana);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this, its clear to see that this is not valid SAS syntax, and you probably received error to indicate this as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding quotes solves this issue but remember that it's case sensitive so Apple is not the same as apple.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let fruitlist = 'apple', 'orange', 'banana';&lt;/PRE&gt;
&lt;P&gt;If you're creating your macro variables from a data step or PROC SQL step, use the QUOTE function to quote them as you add them to the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;

%put &amp;amp;name_list.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Jun 2018 19:11:28 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-06-17T19:11:28Z</dc:date>
    <item>
      <title>create a item list and use for entire code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470901#M120542</link>
      <description>&lt;P&gt;I want to create a item list at the beginning of a SAS code and use it as condition to pull data. Cannot figure out how to do it...&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;%let fruitlist = apple, orange, banana;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from table A&lt;/P&gt;&lt;P&gt;where fruit in (&amp;amp;fruitlist.)&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from table B&lt;/P&gt;&lt;P&gt;where fruit in (&amp;amp;fruitlist.)&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;My code is similar as above. So next time when I want to change condition fruit items, I just need to modify the first line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me on this, thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 18:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470901#M120542</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-17T18:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: create a item list and use for entire code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470905#M120546</link>
      <description>&lt;P&gt;The key thing to remember is that this is direct text replacement. So following that logic, your code becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fruitlist = apple, orange, banana;

select *
from table A
where fruit in (apple, orange, banana);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this, its clear to see that this is not valid SAS syntax, and you probably received error to indicate this as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding quotes solves this issue but remember that it's case sensitive so Apple is not the same as apple.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let fruitlist = 'apple', 'orange', 'banana';&lt;/PRE&gt;
&lt;P&gt;If you're creating your macro variables from a data step or PROC SQL step, use the QUOTE function to quote them as you add them to the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;

%put &amp;amp;name_list.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 19:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470905#M120546</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-17T19:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: create a item list and use for entire code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470907#M120548</link>
      <description>oh, my mistake, in real case my items in lists are numbers, that is why I miss '' in my example</description>
      <pubDate>Sun, 17 Jun 2018 19:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470907#M120548</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-17T19:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: create a item list and use for entire code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470911#M120550</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184299"&gt;@leonzheng&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;oh, my mistake, in real case my items in lists are numbers, that is why I miss '' in my example&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, I can only comment on what you show. If this doesn't resolve your problem you need to provide more details of what you want and what isn't working - and what not working means.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 19:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-item-list-and-use-for-entire-code/m-p/470911#M120550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-17T19:22:01Z</dc:date>
    </item>
  </channel>
</rss>

