<?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: common table expression in sas? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407400#M99268</link>
    <description>&lt;P&gt;The errors actually start at the very beginning. I need to change something before the with statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;14839 PROC SQL;&lt;/P&gt;&lt;P&gt;14840 CREATE TABLE WW_TAYLOR_DM AS&lt;/P&gt;&lt;P&gt;14841 WITH INPUT_DATE_IND AS&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;202&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: (, SELECT.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;14842 (&lt;/P&gt;&lt;P&gt;14843 SELECT MAX(ORIGINALRUNDATE1) AS ORIGINALRUNDATE1&lt;/P&gt;&lt;P&gt;14844 FROM AAA_CM_FILE_NEW&lt;/P&gt;&lt;P&gt;14845 )&lt;/P&gt;&lt;P&gt;14846 ,INPUT_IND_1_FILE AS&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, EXCEPT, INTERSECT, ORDER, OUTER,&lt;/P&gt;&lt;P&gt;UNION.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; WW_TAYLOR_DM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;WITH INPUT_DATE_IND &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MAX(ORIGINALRUNDATE1) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ORIGINALRUNDATE1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AAA_CM_FILE_NEW &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;,INPUT_IND_1_FILE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MEMBERNBR &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MEMBER_NBR&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 18:09:14 GMT</pubDate>
    <dc:creator>gjs</dc:creator>
    <dc:date>2017-10-25T18:09:14Z</dc:date>
    <item>
      <title>common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407313#M99244</link>
      <description>&lt;P&gt;Is it possible to use common table expression in a proc sql statement in sas?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407313#M99244</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T14:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407324#M99247</link>
      <description>&lt;P&gt;What do you mean by "common table expression" ?&lt;/P&gt;
&lt;P&gt;Can you give an example ?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407324#M99247</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T15:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407326#M99249</link>
      <description>&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;WITH WAVE_HIST_GP_25 AS&lt;BR /&gt;(&lt;BR /&gt;SELECT DISTINCT MEMBER_NBR&lt;BR /&gt;,MASTER_MEMBER_ID&lt;BR /&gt;,WAVE_ID&lt;BR /&gt;,WAVE_ID + 1 AS CURR_WAVE&lt;BR /&gt;,CHANNEL_DESC&lt;BR /&gt;,TEST_CELL&lt;BR /&gt;,LOAD_DATE&lt;BR /&gt;,SEGMENT_DESC&lt;BR /&gt;,NEW_WAVE_DT&lt;BR /&gt;,CODE&lt;BR /&gt;FROM hist_file&lt;BR /&gt;WHERE NEW_WAVE_DT = SYSDATE&lt;BR /&gt;)&lt;BR /&gt;SELECT WAVE_HIST_GP_25.MEMBER_NBR&lt;BR /&gt;,WAVE_HIST_GP_25.MASTER_MEMBER_ID&lt;BR /&gt;,WAVE_HIST_GP_25.WAVE_ID&lt;BR /&gt;,WAVE_HIST_GP_25.CURR_WAVE&lt;BR /&gt;,WAVE_HIST_GP_25.CHANNEL_DESC&lt;BR /&gt;,WAVE_HIST_GP_25.TEST_CELL&lt;BR /&gt;,WAVE_HIST_GP_25.LOAD_DATE&lt;BR /&gt;,WAVE_HIST_GP_25.SEGMENT_DESC&lt;BR /&gt;,WAVE_HIST_GP_25.NEW_WAVE_DT&lt;BR /&gt;,WAVE_HIST_GP_25.CODE&lt;BR /&gt;FROM WAVE_HIST_GP_25&lt;BR /&gt;WHERE UPPER(WAVE_HIST_GP_25.SEGMENT_DESC) = 'IN'&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407326#M99249</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407329#M99251</link>
      <description>&lt;P&gt;It seems your "common table expession" is a part of SQL code.&lt;/P&gt;
&lt;P&gt;In sas you can use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    ... your common expression ...
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TRy it and post your full code / log if you need more help.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407329#M99251</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T15:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407340#M99254</link>
      <description>&lt;P&gt;If I understand you correctly (and that's a huge IF in this case), it seems like you want to take the code that you supplied, and utilize it in a number of different SELECT statements.&amp;nbsp; If that's the idea, a SAS macro would come in handy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro GP25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*** All the code you supplied goes here ... do not add a semicolon ***&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend GP25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now any time you want to add that code as part of a SELECT statement or clause, just insert:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%GP25&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That inserts the code, character by character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you intend to do this across multiple programs, there are ways to save the macro definition and easily make it available to many programs.&amp;nbsp; First, let's see if that's what&amp;nbsp;you hope to accomplish.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407340#M99254</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-25T15:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407351#M99259</link>
      <description>&lt;P&gt;It ran. Do you know why this error is appearing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;9963&amp;nbsp; ,INPUT_IND_1_FILE.EMAIL_ADDRESS&lt;/P&gt;&lt;P&gt;9964&amp;nbsp; ,CASE WHEN HCC_IND_1.HCC_FIRST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_FIRST_NAME1&lt;/P&gt;&lt;P&gt;9964! AS HCC_FIRST_NAME&lt;/P&gt;&lt;P&gt;&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; 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;,&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;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,&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; LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;9965&amp;nbsp; ,CASE WHEN HCC_IND_1.HCC_LAST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_LAST_NAME1 AS&lt;/P&gt;&lt;P&gt;9965! HCC_LAST_NAME&lt;/P&gt;&lt;P&gt;9966&amp;nbsp; FROM INPUT_IND_1_FILE&lt;/P&gt;&lt;P&gt;9967&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LEFT JOIN HCC_IND_1 ON INPUT_IND_1_FILE.MEMBER_NBR = HCC_IND_1.MEMBER_NBR&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;Code for this part:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;,INPUT_IND_1_FILE.EMAIL_ADDRESS&lt;/P&gt;&lt;P&gt;,CASE WHEN HCC_IND_1.HCC_FIRST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_FIRST_NAME1 AS HCC_FIRST_NAME&lt;/P&gt;&lt;P&gt;,CASE WHEN HCC_IND_1.HCC_LAST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_LAST_NAME1 AS HCC_LAST_NAME&lt;/P&gt;&lt;P&gt;FROM INPUT_IND_1_FILE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LEFT JOIN HCC_IND_1 ON INPUT_IND_1_FILE.MEMBER_NBR = HCC_IND_1.MEMBER_NBR&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 16:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407351#M99259</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T16:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407364#M99260</link>
      <description>&lt;P&gt;If you have it set up you can also use explicit pass through, where the DB query is sent directly to the DB rather than having to convert to SAS at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code, as written will not run. It does need modifications, but it's possible to replicate within SAS. However, it's probably easier if you tell us what you're trying to accomplish and we can suggest the most appropriate SAS methodology to achieve those results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 16:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407364#M99260</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-25T16:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407385#M99264</link>
      <description>&lt;P&gt;Syntax error: Your CASE expression is missing the END keyword at the end.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 17:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407385#M99264</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-25T17:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407393#M99265</link>
      <description>&lt;P&gt;Still have error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;14898 ,CASE WHEN HCC_IND_1.HCC_FIRST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_FIRST_NAME1&lt;/P&gt;&lt;P&gt;14898! END AS HCC_FIRST_NAME&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;202&lt;/P&gt;&lt;P&gt;14899 ,CASE WHEN HCC_IND_1.HCC_LAST_NAME1 IS NULL THEN 'RHONDA' ELSE HCC_IND_1.HCC_LAST_NAME1&lt;/P&gt;&lt;P&gt;14899! END AS HCC_LAST_NAME&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;,&lt;/P&gt;&lt;P&gt;&amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS,&lt;/P&gt;&lt;P&gt;LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;14900 FROM INPUT_IND_1_FILE&lt;/P&gt;&lt;P&gt;14901 LEFT JOIN HCC_IND_1 ON INPUT_IND_1_FILE.MEMBER_NBR = HCC_IND_1.MEMBER_NBR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 17:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407393#M99265</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T17:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407400#M99268</link>
      <description>&lt;P&gt;The errors actually start at the very beginning. I need to change something before the with statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;14839 PROC SQL;&lt;/P&gt;&lt;P&gt;14840 CREATE TABLE WW_TAYLOR_DM AS&lt;/P&gt;&lt;P&gt;14841 WITH INPUT_DATE_IND AS&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;202&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: (, SELECT.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;14842 (&lt;/P&gt;&lt;P&gt;14843 SELECT MAX(ORIGINALRUNDATE1) AS ORIGINALRUNDATE1&lt;/P&gt;&lt;P&gt;14844 FROM AAA_CM_FILE_NEW&lt;/P&gt;&lt;P&gt;14845 )&lt;/P&gt;&lt;P&gt;14846 ,INPUT_IND_1_FILE AS&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, EXCEPT, INTERSECT, ORDER, OUTER,&lt;/P&gt;&lt;P&gt;UNION.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; WW_TAYLOR_DM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;WITH INPUT_DATE_IND &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MAX(ORIGINALRUNDATE1) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ORIGINALRUNDATE1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AAA_CM_FILE_NEW &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;,INPUT_IND_1_FILE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MEMBERNBR &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MEMBER_NBR&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407400#M99268</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T18:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407402#M99270</link>
      <description>&lt;P&gt;When posting logs, use the {i} icon. It preserves formatting and therefore the horizontal position of error indicators, which is crucial in detecting the cause.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407402#M99270</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-25T18:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407403#M99271</link>
      <description>&lt;P&gt;The error must originate somewhere before those lines. Please post your log using the {i} icon above&amp;nbsp;to preserve column alignment.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407403#M99271</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-25T18:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407407#M99275</link>
      <description>&lt;P&gt;There is no WITH clause in SAS/SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407407#M99275</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-25T18:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407408#M99276</link>
      <description>So common table expressions can't be used in SAS?</description>
      <pubDate>Wed, 25 Oct 2017 18:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407408#M99276</guid>
      <dc:creator>gjs</dc:creator>
      <dc:date>2017-10-25T18:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407410#M99278</link>
      <description>&lt;P&gt;What are &lt;EM&gt;common table expressions&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407410#M99278</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-25T18:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407418#M99281</link>
      <description>&lt;P&gt;It seems to me that CTE's are a nonstandard Microsoft extension to the SQL language. If I read it right, they are more or less a sophisticated variant of a subquery.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407418#M99281</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-25T18:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407424#M99284</link>
      <description>&lt;P&gt;the CTE you have shown can be easily emulated by a derived table&lt;/P&gt;
&lt;PRE&gt;SELECT MEMBER_NBR
,WAVE_HIST_GP_25.MASTER_MEMBER_ID
,WAVE_HIST_GP_25.WAVE_ID
,WAVE_HIST_GP_25.CURR_WAVE
,WAVE_HIST_GP_25.CHANNEL_DESC
,WAVE_HIST_GP_25.TEST_CELL
,WAVE_HIST_GP_25.LOAD_DATE
,WAVE_HIST_GP_25.SEGMENT_DESC
,WAVE_HIST_GP_25.NEW_WAVE_DT
,WAVE_HIST_GP_25.CODE

 from 
(
SELECT DISTINCT MEMBER_NBR
,MASTER_MEMBER_ID
,WAVE_ID
,WAVE_ID + 1 AS CURR_WAVE
,CHANNEL_DESC
,TEST_CELL
,LOAD_DATE
,SEGMENT_DESC
,NEW_WAVE_DT
,CODE
FROM hist_file
WHERE NEW_WAVE_DT = SYSDATE
)WAVE_HIST_GP_25

WHERE UPPER(SEGMENT_DESC) = 'IN'
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 18:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407424#M99284</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-10-25T18:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407434#M99288</link>
      <description>&lt;P&gt;No.&amp;nbsp; PROC SQL uses SQL 92 standard. The WITH clause is not supported.&lt;/P&gt;
&lt;P&gt;Instead of coding something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;with X as (select ....)
select ...
from X
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will need to use something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select ...
from (select ....) X
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 19:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/407434#M99288</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-25T19:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/443024#M110807</link>
      <description>&lt;P&gt;The only way I know to use CTEs in SAS is to do a passthrough query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
connect to ODBC as myconn
(datasrc="SourceName" user=xxx password=xxx);
create table work.test as
select *
from connection to myconn
(
with ....
etc etc

);
disconnect from myconn;
quit;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Mar 2018 20:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/443024#M110807</guid>
      <dc:creator>Josers18</dc:creator>
      <dc:date>2018-03-06T20:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: common table expression in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/443034#M110813</link>
      <description>&lt;P&gt;Pass-Through queries have nothing to do within SAS. These queries run in-database. Since WITH clause is native to database your passing-through its works fine. If you want to run the query in SAS environment you need to convert to SAS syntax style.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see in your query your have SASDATE, is this some variable in your table or your want the SYSTEM Date. If looking for SYSTEM Date then use &amp;amp;SYSDATE macro variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 20:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/common-table-expression-in-sas/m-p/443034#M110813</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-06T20:35:10Z</dc:date>
    </item>
  </channel>
</rss>

