<?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: PROC SQL in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574682#M7898</link>
    <description>&lt;P&gt;When you use macro variables like &amp;amp;LIST in SAS code, they are replaced by the value of the macro variable when the code executes, and this MUST result in valid legal working SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE T2.MAT_COD IN &amp;amp;List;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;when you execute this, the value of macro variable &amp;amp;LIST is used and this results in code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where t2.mat_cod in 63000000000014,63000000000015,63000000000013,...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and this is not valid legal working SAS code — do you see the error now? What is missing that would make this valid legal working SAS code? (hint, the ERROR message tells you specifically what SAS is expecting)&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 17:15:43 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-07-18T17:15:43Z</dc:date>
    <item>
      <title>PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574677#M7896</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello, I have a node to extract data from database, below is my code. The List contains a column from 1st database, and extract a data whose MAT value is in List.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;SELECT MATERIAL into: List separated by ',' FROM EMWS3.FILTER_TRAIN;&lt;BR /&gt;CREATE TABLE RETRIEVE_LIST AS&lt;BR /&gt;SELECT T2.BAT_NUM,&lt;BR /&gt;T2.MAT_COD,&lt;BR /&gt;T2.UNRESTRICTED_QTY&lt;BR /&gt;FROM EMWS3.Ids_DATA AS T2&lt;BR /&gt;WHERE T2.MAT_COD IN &amp;amp;List;&lt;BR /&gt;SELECT * FROM RETRIEVE_LIST;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running the code, the errors pop up:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;7915 CREATE TABLE RETRIEVE_LIST AS&lt;BR /&gt;7916 SELECT T2.BAT_NUM,&lt;BR /&gt;7917 T2.MAT_COD,&lt;BR /&gt;7918 T2.UNRESTRICTED_QTY&lt;BR /&gt;7919 FROM EMWS3.Ids_DATA AS T2&lt;BR /&gt;7920 WHERE T2.MAT_COD IN &amp;amp;List;&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;BR /&gt;NOTE: Line generated by the macro variable "LIST".&lt;BR /&gt;7920 63000000000014,63000000000015,63000000000013,10000000127482,10000000127483,10000000127484,10000000030330,10000000039898,10000000042667,10000000062024,10000000078514,10000000081175,10010000000076,10010000000109,61000000000254,61000000000596,R10&lt;BR /&gt;6&lt;BR /&gt;______________&lt;BR /&gt;______&lt;BR /&gt;&lt;BR /&gt;22 76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: (, SELECT.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;7920 ! 63000000000014,63000000000015,63000000000013,10000000127482,10000000127483,10000000127484,10000000030330,10000000039898,10000000042667,10000000062024,10000000078514,10000000081175,10010000000076,10010000000109,61000000000254,61000000000596,R10&lt;BR /&gt;6&lt;/P&gt;&lt;P&gt;______&lt;BR /&gt;&lt;BR /&gt;22&lt;BR /&gt;7920 ! 63,R11274,&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, ), -.&lt;BR /&gt;7921 SELECT * FROM RETRIEVE_LIST;&lt;BR /&gt;NOTE: Statement not executed due to NOEXEC option.&lt;BR /&gt;7922 QUIT;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: The PROCEDURE SQL printed page 13.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.14 seconds&lt;BR /&gt;cpu time 0.14 seconds&lt;BR /&gt;&lt;BR /&gt;7922 !&lt;BR /&gt;7923&lt;BR /&gt;7924 /*; *"; *'; */;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please advice on this?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 17:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574677#M7896</guid>
      <dc:creator>Jonison</dc:creator>
      <dc:date>2019-07-18T17:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574679#M7897</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Assuming your material variable is of type char, the following may work*/
/*quote each value of material before you load them into a macro var list*/

PROC SQL;
SELECT quote(MATERIAL) into: List separated by ',' FROM EMWS3.FILTER_TRAIN;
CREATE TABLE RETRIEVE_LIST AS
SELECT T2.BAT_NUM,
T2.MAT_COD,
T2.UNRESTRICTED_QTY
FROM EMWS3.Ids_DATA AS T2
WHERE T2.MAT_COD IN (&amp;amp;List);/*notice the parenthesis*/
SELECT * FROM RETRIEVE_LIST;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 17:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574679#M7897</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-18T17:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574682#M7898</link>
      <description>&lt;P&gt;When you use macro variables like &amp;amp;LIST in SAS code, they are replaced by the value of the macro variable when the code executes, and this MUST result in valid legal working SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE T2.MAT_COD IN &amp;amp;List;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;when you execute this, the value of macro variable &amp;amp;LIST is used and this results in code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where t2.mat_cod in 63000000000014,63000000000015,63000000000013,...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and this is not valid legal working SAS code — do you see the error now? What is missing that would make this valid legal working SAS code? (hint, the ERROR message tells you specifically what SAS is expecting)&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 17:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574682#M7898</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-18T17:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574906#M7906</link>
      <description>&lt;P&gt;Many thanks for suggestions&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 11:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL/m-p/574906#M7906</guid>
      <dc:creator>Jonison</dc:creator>
      <dc:date>2019-07-19T11:05:26Z</dc:date>
    </item>
  </channel>
</rss>

