<?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 SQL and Select from Macro Variable List in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578744#M164187</link>
    <description>&lt;P&gt;I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let ac_grp = "N02299 N99761 N79986 N99121 N01899 N09955";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CREATE TABLE EGTASK.TESTER AS&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;FROM EGTASK.ENR_CURR_V4 (where= (client_id = (&amp;amp;ac_grp)));&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This ends up not picking anything up from the original table. The client_ids are in the ac_grp macro variable.&amp;nbsp; Probably something easy that I'm missing.&amp;nbsp; Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2019 15:22:37 GMT</pubDate>
    <dc:creator>BCNAV</dc:creator>
    <dc:date>2019-08-02T15:22:37Z</dc:date>
    <item>
      <title>SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578744#M164187</link>
      <description>&lt;P&gt;I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let ac_grp = "N02299 N99761 N79986 N99121 N01899 N09955";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CREATE TABLE EGTASK.TESTER AS&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;FROM EGTASK.ENR_CURR_V4 (where= (client_id = (&amp;amp;ac_grp)));&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This ends up not picking anything up from the original table. The client_ids are in the ac_grp macro variable.&amp;nbsp; Probably something easy that I'm missing.&amp;nbsp; Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578744#M164187</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2019-08-02T15:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578746#M164188</link>
      <description>Not valid SAS sytnaxt. &lt;BR /&gt;&lt;BR /&gt;I'm guessing you want:&lt;BR /&gt;&lt;BR /&gt;%let ac_grp = "N02299", N99761", "N79986" ....</description>
      <pubDate>Fri, 02 Aug 2019 15:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578746#M164188</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-02T15:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578747#M164189</link>
      <description>(where= (client_id IN (&amp;amp;ac_grp)));&lt;BR /&gt;&lt;BR /&gt;Change = to IN as well.</description>
      <pubDate>Fri, 02 Aug 2019 15:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578747#M164189</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-02T15:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578751#M164191</link>
      <description>&lt;P&gt;Adding to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s comment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These types of macro errors can be avoided by first creating code that works on just a small number of cases (such as just these two&amp;nbsp;&lt;SPAN&gt;N02299 N99761 hard coded)&lt;/SPAN&gt; WITHOUT MACROs and WITHOUT MACRO VARIABLEs. Once you have code that works without any macro code, then converting it to macros will have a higher probability of working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then if you hard&amp;nbsp; coded these first in your code, you would see that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
     CREATE TABLE EGTASK.TESTER AS
     SELECT *
     FROM EGTASK.ENR_CURR_V4 (where= (client_id = ("N02299 N99761")));
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;doesn't work. If you get the above to work, your macro will probably work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578751#M164191</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-02T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578752#M164192</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let ac_grp = "N02299" "N99761" "N79986" "N99121" "N01899" "N09955";

PROC SQL;
     CREATE TABLE EGTASK.TESTER AS
     SELECT *
     FROM EGTASK.ENR_CURR_V4 (where= (client_id &lt;FONT color="#ff00ff"&gt;&lt;STRONG&gt;in &lt;/STRONG&gt;&lt;/FONT&gt;(&amp;amp;ac_grp)));
QUIT;
&lt;/PRE&gt;
&lt;P&gt;It may also help to consider a version of the code that worked without any macro elements at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You were comparing individual values of the client_id to an aggregated list (one long single value)&amp;nbsp;not looking for it match any of the components of the list.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578752#M164192</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-02T15:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578758#M164195</link>
      <description>&lt;P&gt;Can't believe I forgot the quotes in the list....bah!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks all&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578758#M164195</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2019-08-02T15:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL and Select from Macro Variable List</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578761#M164197</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/142314"&gt;@BCNAV&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can't believe I forgot the quotes in the list....bah!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks all&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The use of = instead of IN would have created an error with the properly quoted list.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-and-Select-from-Macro-Variable-List/m-p/578761#M164197</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-02T15:49:13Z</dc:date>
    </item>
  </channel>
</rss>

