BookmarkSubscribeRSS Feed
psjksh
SAS Employee

Hi,

 

I am trying to write a DS2 code in RTDM. This is because I am not able to use Tableselect in calculated variables because FINDW function is not available. I cannot use FIND because I have to find the exact match.

 

Is there a limit on DS2 code based on the errors below? Or is there any alternative for this? Basically, I'm trying to filter the data grid in such a way that it will only output those that meet the condition. Thank you.

 

Sample1

PARAMETER - "DEVICE_X|DEVICE_Y|DEVICE_Z" (constant value, extracted from DB table)

CHECK - "DEVICE" (dynamic value and 1 customer can have multiple values, from the source data grid)

Output should be 0

FINDW(PARAMETER, CHECK) = 0 is true (this should not be part of the data grid output)

 

Sample2

PARAMETER - "DEVICE_X|DEVICE_Y|DEVICE_Z" (constant value, extracted from DB table)

CHECK - "DEVICE_X" (dynamic value and 1 customer can have multiple values, from the source data grid)

Output should be > 0

FINDW(PARAMETER, CHECK) > 0 is true (this should be part of the data grid output)

 

My source data grid has 195 columns and I have to output the same columns plus a new column that was calculated from the FINDW function. FINDW is working in the code, but when I output all the columns I am hitting error. I added columns by batch in the script to see where it is failing. Some columns are okay, and some columns are hitting below error.

 

com.sas.analytics.ph.RTDMException: Error executing activity
at com.sas.rtdm.implementation.EventExecutor.execute(EventExecutor.java:255)
at com.sas.rtdm.implementation.TestExecutor.execute(TestExecutor.java:209)
at com.sas.rtdm.implementation.engine.ActivityNode._execute(ActivityNode.java:58)
at com.sas.rtdm.implementation.engine.ActivityNode._execute(ActivityNode.java:18)
at com.sas.rtdm.implementation.engine.SchedulableNode$1.call(SchedulableNode.java:89)
at com.sas.rtdm.implementation.engine.SchedulableNode$1.call(SchedulableNode.java:82)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 8187
at java.lang.String.charAt(String.java:658)
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding.tokenize(DS2ObjectEncoding.java:494)
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding._decodeTableStr(DS2ObjectEncoding.java:352)
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding.decodeTableStr(DS2ObjectEncoding.java:296)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.getOutputValues(DS2Activity.java:439)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.handle_output(DS2Activity.java:316)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.execute(DS2Activity.java:228)
at com.sas.rtdm.implementation.EventExecutor.execute(EventExecutor.java:243)
... 9 more

 

This is excerpt from the code

 

package CHECK_PARAM/overwrite=yes;

 

dcl varchar(100) VAR58  /*sample column that hits error*/

 

method execute(
package tap_table DATAGRID,
varchar(500) PARAMETER,
in_out package tap_table DATAGRID_2
);
 
dcl int i_row;
 
DATAGRID_2.clear();
DATAGRID_2.add_column('VAR58','String');
 
if  DATAGRID.row_count() > 0 then do;
 
i_row=1;
do while ( i_row <= DATAGRID.row_count() );
              VAR58 = DATAGRID.getString('VAR58'||'',i_row);  

 

/*Load data*/
DATAGRID_2.add_row();

DATAGRID_2.setString('VAR58 ',i_row,VAR58);

 

i_row = i_row + 1;
 
end;/*end do while statement (DATAGRID_2)*/
 
end;/*end do statement*/
 
end; /*End Method Execute*/
endpackage; /*End Package*/
run;
quit;
 

Also, when I try to process more than 2 rows, I am hitting this error "Not enough tokens" / java.util.NoSuchElementException

 

2023-09-12 16:44:26,409 WARN sasdemo SASDSDesignRepository Test Case 4 com.sas.rtdm.implementation.TestExecutor - Execution faulted:
Not enough tokens. Encoded data: "t560194

 

com.sas.analytics.ph.RTDMException: java.util.NoSuchElementException
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding.decodeTableStr(DS2ObjectEncoding.java:299)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.getOutputValues(DS2Activity.java:439)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.handle_output(DS2Activity.java:316)
at com.sas.rtdm.implementation.activity.sasactivity.DS2Activity.execute(DS2Activity.java:228)
at com.sas.rtdm.implementation.EventExecutor.execute(EventExecutor.java:243)
at com.sas.rtdm.implementation.TestExecutor.execute(TestExecutor.java:209)
at com.sas.rtdm.implementation.engine.ActivityNode._execute(ActivityNode.java:58)
at com.sas.rtdm.implementation.engine.ActivityNode._execute(ActivityNode.java:18)
at com.sas.rtdm.implementation.engine.SchedulableNode$1.call(SchedulableNode.java:89)
at com.sas.rtdm.implementation.engine.SchedulableNode$1.call(SchedulableNode.java:82)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.NoSuchElementException
at java.util.LinkedList.removeFirst(LinkedList.java:270)
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding._decodeTableStr(DS2ObjectEncoding.java:402)
at com.sas.rtdm.implementation.activity.sasactivity.DS2ObjectEncoding.decodeTableStr(DS2ObjectEncoding.java:296)
... 13 more

 

Appreciate feedback on this. Thank you

 

1 REPLY 1
sbxkoenk
SAS Super FREQ

Home > SAS staff only here! > Employee Lounge
Employees: Where to get YOUR SAS user questions answered?
by BerverlyBrown
https://communities.sas.com/t5/Employee-Lounge/Employees-Where-to-get-YOUR-SAS-user-questions-answer...

 

Koen

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 157 views
  • 0 likes
  • 2 in conversation