<?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 Error using With and Row_Number Over Partition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778494#M247803</link>
    <description>&lt;P&gt;You wont be able to run this code as a test however Im attemtping to determine why I am getting this error&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table test1 as

WITH  FCSCHED 		AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Scheduled */ 
		SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN
				,T_FORECLSURE_STEP.LN_NO
				,T_FORECLSURE_STEP.FC_SETUP_DT
				,T_FORECLSURE_STEP.FS_STEP_CD
				,T_FORECLSURE_STEP.FS_SCHED_COMPL_DT
				,T_FORECLSURE_STEP.FS_ACTUAL_COMPL_DT
		FROM _dbeappl.T_FORECLSURE_STEP T_FORECLSURE_STEP
		WHERE (T_FORECLSURE_STEP.FS_STEP_CD In ('075'))	
	)
	,FCHELD 		AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Held */ 
		SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN
				,T_FORECLSURE_STEP.LN_NO
				,T_FORECLSURE_STEP.FC_SETUP_DT
				,T_FORECLSURE_STEP.FS_STEP_CD
				,T_FORECLSURE_STEP.FS_SCHED_COMPL_DT
				,T_FORECLSURE_STEP.FS_ACTUAL_COMPL_DT
		FROM _dbeappl.T_FORECLSURE_STEP T_FORECLSURE_STEP
		WHERE (T_FORECLSURE_STEP.FS_STEP_CD In ('078','080'))
	)

	SELECT  a.LN_NO
           ,FCSCHED.FS_ACTUAL_COMPL_DT AS FC_SALE_SCHED
	       ,FCHELD.FS_ACTUAL_COMPL_DT AS FC_SALE_HELD

		   FROM 

		   (select distinct LN_NO from _dbeappl.T_LONG_COMMENT
            where LONG_COMM_CD IN ('DFCRND','DFCRD6','DFCORN','DFCRN6') 
            AND LN_NO &amp;lt;&amp;gt; '0121133333') a 
           LEFT JOIN FCSCHED ON (a.LN_NO = FCSCHED.LN_NO AND FCSCHED.RN = 1)
		   LEFT JOIN FCHELD ON (a.LN_NO = FCHELD.LN_NO AND FCHELD.RN = 1)


;quit;&lt;/PRE&gt;
&lt;P&gt;47 proc sql;&lt;BR /&gt;48 create table test1 as&lt;BR /&gt;49 &lt;BR /&gt;50 WITH FCSCHED AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Scheduled */&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&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;51 SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 14:34:08 GMT</pubDate>
    <dc:creator>Q1983</dc:creator>
    <dc:date>2021-11-04T14:34:08Z</dc:date>
    <item>
      <title>Error using With and Row_Number Over Partition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778494#M247803</link>
      <description>&lt;P&gt;You wont be able to run this code as a test however Im attemtping to determine why I am getting this error&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table test1 as

WITH  FCSCHED 		AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Scheduled */ 
		SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN
				,T_FORECLSURE_STEP.LN_NO
				,T_FORECLSURE_STEP.FC_SETUP_DT
				,T_FORECLSURE_STEP.FS_STEP_CD
				,T_FORECLSURE_STEP.FS_SCHED_COMPL_DT
				,T_FORECLSURE_STEP.FS_ACTUAL_COMPL_DT
		FROM _dbeappl.T_FORECLSURE_STEP T_FORECLSURE_STEP
		WHERE (T_FORECLSURE_STEP.FS_STEP_CD In ('075'))	
	)
	,FCHELD 		AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Held */ 
		SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN
				,T_FORECLSURE_STEP.LN_NO
				,T_FORECLSURE_STEP.FC_SETUP_DT
				,T_FORECLSURE_STEP.FS_STEP_CD
				,T_FORECLSURE_STEP.FS_SCHED_COMPL_DT
				,T_FORECLSURE_STEP.FS_ACTUAL_COMPL_DT
		FROM _dbeappl.T_FORECLSURE_STEP T_FORECLSURE_STEP
		WHERE (T_FORECLSURE_STEP.FS_STEP_CD In ('078','080'))
	)

	SELECT  a.LN_NO
           ,FCSCHED.FS_ACTUAL_COMPL_DT AS FC_SALE_SCHED
	       ,FCHELD.FS_ACTUAL_COMPL_DT AS FC_SALE_HELD

		   FROM 

		   (select distinct LN_NO from _dbeappl.T_LONG_COMMENT
            where LONG_COMM_CD IN ('DFCRND','DFCRD6','DFCORN','DFCRN6') 
            AND LN_NO &amp;lt;&amp;gt; '0121133333') a 
           LEFT JOIN FCSCHED ON (a.LN_NO = FCSCHED.LN_NO AND FCSCHED.RN = 1)
		   LEFT JOIN FCHELD ON (a.LN_NO = FCHELD.LN_NO AND FCHELD.RN = 1)


;quit;&lt;/PRE&gt;
&lt;P&gt;47 proc sql;&lt;BR /&gt;48 create table test1 as&lt;BR /&gt;49 &lt;BR /&gt;50 WITH FCSCHED AS (/*CRITERIA: Pull FC sep Details, Use Row number and Setup date to Find most recent actions for FC Sales Scheduled */&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&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;51 SELECT ROW_NUMBER() over(Partition by T_FORECLSURE_STEP.LN_NO Order by T_FORECLSURE_STEP.FC_SETUP_DT DESC) AS RN&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 14:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778494#M247803</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-11-04T14:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error using With and Row_Number Over Partition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778495#M247804</link>
      <description>&lt;P&gt;You are not using valid SQL.&amp;nbsp; Neither WITH nor OVER and not part of the ANSI standard from 1992 that PROC SQL implements.&amp;nbsp; SAS does not have a function named ROW_NUMBER.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 14:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778495#M247804</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-04T14:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error using With and Row_Number Over Partition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778496#M247805</link>
      <description>&lt;P&gt;You don't have to use SQL in SAS to get things done. Unlike a lot of DBMS systems SAS has its own language for manipulating data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what you are trying to do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can get it done using the DATA step and/or procedures such as PROC FREQ, PROC SUMMARY, PROC RANK, etc..&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 14:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778496#M247805</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-04T14:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error using With and Row_Number Over Partition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778518#M247819</link>
      <description>&lt;P&gt;Please place LOG entries in a text box. Then the diagnostic characters that appear in your multiple error messages will appear in the relative place showing exactly the problem location. Such as WITH is not a SAS Proc SQL&amp;nbsp; statement.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778518#M247819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-04T16:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Error using With and Row_Number Over Partition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778527#M247828</link>
      <description>Are you using an Oracle DB? Can you use explicit sql instead? In that case your SQL is passed directly to the server so you can use the Oracle SQL code.</description>
      <pubDate>Thu, 04 Nov 2021 16:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-With-and-Row-Number-Over-Partition/m-p/778527#M247828</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-04T16:37:02Z</dc:date>
    </item>
  </channel>
</rss>

