<?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: Alternative to ROW NUMBER () in SAS DI in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473178#M14847</link>
    <description>&lt;P&gt;You can set the active schema after you created a connection to oracle, see this post for an example&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/how-to-Alter-oracle-current-schema-via-sas-pass-through/td-p/435885" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/how-to-Alter-oracle-current-schema-via-sas-pass-through/td-p/435885&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;, see the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that you can run your Oracle SQL using SQL Pass Through.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jun 2018 21:31:02 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2018-06-25T21:31:02Z</dc:date>
    <item>
      <title>Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472914#M14833</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on SAS DI, and using the user written code feature in it.&lt;/P&gt;&lt;P&gt;And getting the below error in it :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;938&lt;BR /&gt;939 CREATE TABLE WNFTHD AS&lt;BR /&gt;940&lt;BR /&gt;941&lt;BR /&gt;942 /*create table rbm_m_CUSTPRODUCTSTATUS_ACTV_VLS AS */&lt;BR /&gt;943&lt;BR /&gt;944 SELECT&lt;BR /&gt;945 CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM&lt;BR /&gt;946 FROM&lt;BR /&gt;947 (&lt;BR /&gt;948 SELECT&lt;BR /&gt;949 CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM,&lt;BR /&gt;950 ROW_NUMBER() OVER (PARTITION BY CUSTOMER_REF,PRODUCT_SEQ ORDER BY EFFECTIVE_DTM 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,&lt;BR /&gt;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;&lt;P&gt;951 FROM EBUSTG.MOB_CUSTPRODUCTSTATUS B&lt;BR /&gt;952 )P&lt;BR /&gt;953 WHERE&lt;BR /&gt;954 RN=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does SAS DI, user written code does not support the row number () function if yes - what should be the alternative for that.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 10:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472914#M14833</guid>
      <dc:creator>amitvermajhs</dc:creator>
      <dc:date>2018-06-25T10:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472922#M14834</link>
      <description>&lt;P&gt;Row_number() function is a proprietary compiled function by Oracle.&amp;nbsp; It is not available in SAS SQL which is ANSI compliant and does not implement any third party functions.&amp;nbsp; You can, if connecting to a database like oracle, pass through your SQL to the database to run, in which case the functions would be available per the database.&amp;nbsp; Alternatively you would need to re-code your script, either by complicated SQL programming, or by using SAS language which is far simpler:&lt;/P&gt;
&lt;PRE&gt;proc sort data=yourdata out=want;
  by customer_ref product_seq effective_dtm;
run;
data want;
  set want;
  retain row_num;
  if _n_=1 then row_num=1;
  if first.product_seq then row_num=row_num+1;
run;&lt;/PRE&gt;
&lt;P&gt;Or something like that, haven't tested as nothing to test it on.&amp;nbsp; Also avoid SHOUTING code.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 10:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472922#M14834</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-25T10:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472933#M14835</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8488"&gt;@amitvermajhs&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You're using Oracle SQL which is totally fine IF your source table resides in Oracle AND you issue such code as explicit pass-through SQL (which you don't).&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 11:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472933#M14835</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-25T11:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472937#M14836</link>
      <description>&lt;P&gt;I have done all coding in SQL developer, and now need to automate the process in SAS DI. So using the user written code feature in SAS DI, to minimize the efforts. And all my codes have worked fine in SAS DI only the below code is giving error.&lt;/P&gt;&lt;P&gt;I have the source table in Oracle and need to use SAS DI codes to do the processing, guide me to have the alternative for below code , using sas dataset will be lengthy procedure as will need to create libraries&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Till now I was using the below code piece to filter the variable:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create table rbm_m_CUSTPRODUCTSTATUS_ACTV_VLS&lt;BR /&gt;AS&lt;BR /&gt;SELECT&lt;BR /&gt;CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM&lt;BR /&gt;FROM&lt;BR /&gt;(&lt;BR /&gt;SELECT&lt;BR /&gt;CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM,&lt;BR /&gt;ROW_NUMBER() OVER (PARTITION BY CUSTOMER_REF,PRODUCT_SEQ ORDER BY EFFECTIVE_DTM DESC ) AS RN&lt;BR /&gt;FROM MOB_CUSTPRODUCTSTATUS B&lt;BR /&gt;)P&lt;BR /&gt;WHERE&lt;BR /&gt;RN=1;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 11:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472937#M14836</guid>
      <dc:creator>amitvermajhs</dc:creator>
      <dc:date>2018-06-25T11:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472950#M14838</link>
      <description>&lt;P&gt;Then you need to send the code to the database for actioning:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  connect to oracle (...);
  select * from connection to oracle (
    create table rbm_m_CUSTPRODUCTSTATUS_ACTV_VLS
      AS
      SELECT
CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM
FROM
(
SELECT
CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM,
ROW_NUMBER() OVER (PARTITION BY CUSTOMER_REF,PRODUCT_SEQ ORDER BY EFFECTIVE_DTM DESC ) AS RN
FROM MOB_CUSTPRODUCTSTATUS B
)P
WHERE
RN=1);
  disconnect from oracle;
quit;&lt;/PRE&gt;
&lt;P&gt;I have just copied/pasted your code in there, good idea to apply some formatting to make it readable.&lt;/P&gt;
&lt;P&gt;The connection to oracle, you need to put in schema, username, password information etc. I can't provide this to you:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 12:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/472950#M14838</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-25T12:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473018#M14839</link>
      <description>&lt;P&gt;Thanks RW9, but have a query that -&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) My oracle table&amp;nbsp;MOB_CUSTPRODUCTSTATUS is in schema EBU_STG --- so do I need to create a libname to access the table with below code&amp;nbsp;&lt;/P&gt;&lt;P&gt;LIBNAME EBUSTG ORACLE&amp;nbsp; encoding="utf-8"&amp;nbsp; PATH=EBUP&amp;nbsp; SCHEMA=EBU_STG&amp;nbsp; AUTHDOMAIN="EBU_***_***_Domain" ;&lt;/P&gt;&lt;P&gt;2) In connect to oracle I just need to pass the username and pwd i.e.&amp;nbsp;connect to oracle (user=*** password=****), or any other information needs to be passed&lt;/P&gt;&lt;P&gt;3) And in line -&amp;nbsp;create table EBUSTG.rbm_m_CUSTPRODUCTSTATUS_ACTV_VLS --- do I need to provide any libname to guide the system which schema it should write the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Till now I was using the attached diagram in SAS DI to do the operations, and using a physical storage in user written code, and then the table loader to load the data in the dedicated table. Can I do the same with the code provided by you in the user written code.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 14:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473018#M14839</guid>
      <dc:creator>amitvermajhs</dc:creator>
      <dc:date>2018-06-25T14:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473022#M14840</link>
      <description>&lt;P&gt;I am afraid you need to discuss that with your Oracle DB admin/helpdesk.&amp;nbsp; I am not familiar with DI, nor would I open a zip file from the web.&amp;nbsp; It needs someone who knows your systems and their interactions, you may already have connections setup for instance.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 14:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473022#M14840</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-25T14:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473178#M14847</link>
      <description>&lt;P&gt;You can set the active schema after you created a connection to oracle, see this post for an example&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/how-to-Alter-oracle-current-schema-via-sas-pass-through/td-p/435885" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/how-to-Alter-oracle-current-schema-via-sas-pass-through/td-p/435885&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;, see the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that you can run your Oracle SQL using SQL Pass Through.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 21:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473178#M14847</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-06-25T21:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473200#M14850</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8488"&gt;@amitvermajhs&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;1. Amend your code to use &amp;lt;schema name&amp;gt;.&amp;lt;table name&amp;gt;&lt;/P&gt;
&lt;P&gt;2. Execute the amended code in SQL Developer (best with a code window opened under a different schema)&lt;/P&gt;
&lt;P&gt;3. If working copy/paste the code back to DI Studio into the code block for explicit SQL Pass-through&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note:&lt;/P&gt;
&lt;P&gt;IF you want the data transferred back to SAS then it's a select .... from connection to oracle ( &amp;lt;pass through code&amp;gt;);&lt;/P&gt;
&lt;P&gt;IF it's only processing on the DB side (i.e. creating a table in Oracle) then it's in an execute block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do NOT use:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create table &amp;lt;libref to Oracle.table name&amp;gt; .... select ....&amp;nbsp;&lt;SPAN&gt; from connection to oracle ( &amp;lt;pass through code&amp;gt;);&lt;/SPAN&gt; as this would likely first move the data from Oracle to SAS only to then move it back from SAS to Oracle to load the data into a newly created table in Oracle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And last but not least:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DIS best practice is to only use user written code if you really can't implement the logic via standard transformation. Given that you just could copy/past your SQL into SAS SQL I would assume a lot of it could get implemented using the SQL Join transformation without any user written code.&lt;/P&gt;
&lt;P&gt;The moment you use user written code you loose things like data lineage and full impact analysis capabilities.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 23:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473200#M14850</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-25T23:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473626#M14862</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I tried the following code in user written code in SAS DI:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LIBNAME EBUSTG ORACLE encoding="utf-8" PATH=*** SCHEMA=**** AUTHDOMAIN="EBU_STG_Auth_Domain" ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=EBUSTG.MOB_CUSTPRODUCTSTATUS out=WS58287;&lt;BR /&gt;by customer_ref product_seq effective_dtm;&lt;BR /&gt;run;&lt;BR /&gt;data WS58287;&lt;BR /&gt;set WS58287;&lt;BR /&gt;retain row_num;&lt;BR /&gt;if _n_=1 then row_num=1;&lt;BR /&gt;if first.product_seq then row_num=row_num+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And getting the below error message&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG border="0" /&gt;&amp;nbsp;&lt;A href="SCROLL:517005803" target="_blank"&gt;Table Loader&lt;/A&gt;&lt;BR /&gt;&lt;IMG border="0" /&gt;&amp;nbsp;&lt;A href="SELECT:16814:16918" target="_blank"&gt;Line 1,323:&lt;/A&gt; WARNING: Variable row_num was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;&lt;BR /&gt;&lt;IMG border="0" /&gt;&amp;nbsp;&lt;A href="SELECT:17078:17172" target="_blank"&gt;Line 1,323:&lt;/A&gt; ERROR: ROLLBACK issued due to errors for data set EBUSTG.MOB_CUSTPRODUCTSTATUS_ACTV_VLS.DATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please assist on the same.&lt;/P&gt;&lt;P&gt;1) Firstly I am using the source dataset as '&lt;SPAN&gt;EBUSTG.MOB_CUSTPRODUCTSTATUS' as this has the data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) The out dataset is&amp;nbsp;WS58287 as that is the physical storage name in the user define code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3) Getting the warning for Variable row_num was not found on BASE file. The variable will not be added to the BASE file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4) I have the same table structure&amp;nbsp;for source and destinations table i.e.&amp;nbsp;'EBUSTG.MOB_CUSTPRODUCTSTATUS' and&amp;nbsp;EBUSTG.MOB_CUSTPRODUCTSTATUS_ACTV_VLS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;5) I have written the above code in user-written box --&amp;gt; connected it to table loader --&amp;gt; and finally&amp;nbsp;connecting it to destination table i.e.&amp;nbsp;EBUSTG.MOB_CUSTPRODUCTSTATUS_ACTV_VLS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;6) I am attaching the SAS DI diagram in the the attachment DI.zip for reference&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please assist on the same&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 08:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473626#M14862</guid>
      <dc:creator>amitvermajhs</dc:creator>
      <dc:date>2018-06-27T08:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473630#M14863</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have moved all the tables in a single schema, and the below code is working fine in SQL developer and giving me proper results and thus wants to replicate the below in SAS DI.&lt;/P&gt;&lt;P&gt;Please assist where should I write the below code in SAS DI, as till now I am using the Transformations --&amp;gt; Data --&amp;gt; User written code box to write the code and then use table loader to save it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My sql code is as follows :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create table rbm_m_CUSTPRODUCTSTATUS_ACTV_VLS&lt;BR /&gt;AS&lt;BR /&gt;SELECT&lt;BR /&gt;CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM&lt;BR /&gt;FROM&lt;BR /&gt;(&lt;BR /&gt;SELECT&lt;BR /&gt;CUSTOMER_REF,PRODUCT_SEQ,PRODUCT_STATUS,STATUS_REASON_TXT,EFFECTIVE_DTM,&lt;BR /&gt;ROW_NUMBER() OVER (PARTITION BY CUSTOMER_REF,PRODUCT_SEQ ORDER BY EFFECTIVE_DTM DESC ) AS RN&lt;BR /&gt;FROM MOB_CUSTPRODUCTSTATUS B&lt;BR /&gt;)P&lt;BR /&gt;WHERE&lt;BR /&gt;RN=1;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 08:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473630#M14863</guid>
      <dc:creator>amitvermajhs</dc:creator>
      <dc:date>2018-06-27T08:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473631#M14864</link>
      <description>&lt;P&gt;Please avoid using all uppercase in your code, it is shouting.&amp;nbsp; Also please use the code window to post code - it is the {i} above post area.&lt;/P&gt;
&lt;P&gt;You are accessing a table in a database = mob_custproductstatus, this table does not have a variable = row_num, hence you get an error.&lt;/P&gt;
&lt;P&gt;What are you trying to do, you need to plan out your process.&amp;nbsp; Will the data stay on the database, will it come into the SAS environment?&amp;nbsp; If it remains on the database, then passthrough your original query to the database as you will then have access to Oracle functions.&amp;nbsp; If not, then extract the data into SAS and use SAS to process the data.&amp;nbsp; Currently you are trying to do both at the same time which will not work.&lt;/P&gt;
&lt;P&gt;I would start by running this:&lt;/P&gt;
&lt;PRE&gt;libname ebustg oracle encoding="utf-8" path=... authdomain=...;

proc sort data=ebustg.mob_custproductstatus out=ws58287;
  by customer_ref product_seq effective_dtm;
run;&lt;/PRE&gt;
&lt;P&gt;Do you get the data in a dataset in library work?&amp;nbsp; You should do, and be able to process that data using SAS.&amp;nbsp; However that data wouldn't go back to the database as the table there has a different structure - i.e. you have added columns.&amp;nbsp; It would work if you went to the database and updated the table structure there to include a new column called row_num, but I don't think that is the point of this process.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 08:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473631#M14864</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-27T08:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to ROW NUMBER () in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473643#M14865</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8488"&gt;@amitvermajhs&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Here the docu link with examples as a starting point for you:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n05b4mygsvt845n1vnr6r5kchbjf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n05b4mygsvt845n1vnr6r5kchbjf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to stick with the code you've developed in SQL Developer then you need also to stick with user written code AND with Explicit Pass-Through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That won't result in "best practice" SAS DI jobs (which should be metadata driven) but it's eventually the quickest and safest way for you to make things work.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 09:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Alternative-to-ROW-NUMBER-in-SAS-DI/m-p/473643#M14865</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-27T09:20:31Z</dc:date>
    </item>
  </channel>
</rss>

