<?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: RTDM: Reading two data grids and apply filter in SAS Customer Intelligence</title>
    <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/635193#M1470</link>
    <description>&lt;P&gt;Hi,&lt;SPAN&gt;Bhanu&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use Jython to handle data grids in rtdm,can you provide some examples of Jython operating data grids?I can't find any valid data about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lucifer&lt;/P&gt;</description>
    <pubDate>Fri, 27 Mar 2020 05:14:10 GMT</pubDate>
    <dc:creator>TyrantLucifer</dc:creator>
    <dc:date>2020-03-27T05:14:10Z</dc:date>
    <item>
      <title>RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/488878#M994</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a new user to RTDM and trying to apply a filter using two below data grids (A,B), Unfortunately calculated variables has only Tableinnerjoin function available to read two data grids and generates the common records as output data grid.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA GRID A: P1 , P2, P3, P4, P5&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA GRID B: P3, P5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required Output DATA GRID A -B :&amp;nbsp; P1,P2,P4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I couldn't find any ds2 code that reads the data grid as input and creates the output as data grid. I&amp;nbsp;read that tap_table method in ds2 will read the data grid. It would be helpful if you can provide a sample ds2 code snippet to solve my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;RTDM User&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 13:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/488878#M994</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2018-08-22T13:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/489122#M995</link>
      <description>HI bhanucharan,&lt;BR /&gt;I don't believe there is a nice function to do this, so you will need to iterate through one datagrid, and then in a sub-loop iterate through the second, comparing the values of P3 and P5 as you go, and then conditionally output the record to a new datagrid when they are not matched. Below is some incomplete sample code to show how to instantiate the data grids for inputs and outputs, including creating the new columns for output, You will need to use the get&lt;TYPE&gt; methods of the tap_table package (for example getString or getFloat) to retrieve the values from the data grids as you iterate through them, and then check for equality to decide if you have a match, then use the set&lt;TYPE&gt; methods to write to row and column into the output.&lt;BR /&gt;HTH,&lt;BR /&gt;James&lt;BR /&gt;package MyDS2Package / overwrite=yes;&lt;BR /&gt;    dcl package tap_logger m_logger();&lt;BR /&gt;              dcl varchar(10) tmp_A_P3 tmp_A_P5 tmp_B_P3 tmp_B_P5;&lt;BR /&gt;    dcl int rowA rowB ;&lt;BR /&gt;        method execute(&lt;BR /&gt;      package tap_table MyInputDataGrid_A MyInputDataGrid_B,&lt;BR /&gt;      in_out package tap_table MyOutputDataGrid&lt;BR /&gt;      );&lt;BR /&gt;            myPackageName = 'MyDS2Package: ' ;&lt;BR /&gt;&lt;BR /&gt;      if (m_logger.isDebugEnabled()) then do ;&lt;BR /&gt;        m_logger.debug(myPackageName|| 'Entered execute method');&lt;BR /&gt;      end ;&lt;BR /&gt;&lt;BR /&gt;      m_logger.debug(myPackageName|| 'Adding columns.');&lt;BR /&gt;&lt;BR /&gt;      MyOutputDataGrid.add_column('P1', 'string');&lt;BR /&gt;      MyOutputDataGrid.add_column('P2', 'string');&lt;BR /&gt;      MyOutputDataGrid.add_column('P4', 'string');&lt;BR /&gt;&lt;BR /&gt;      m_logger.debug(myPackageName|| 'Adding Rows.');&lt;BR /&gt;&lt;BR /&gt;                do  rowA = 1 to MyInputDataGrid_A.row_count() ;&lt;BR /&gt;&lt;BR /&gt;                              /* your comparision logic here */&lt;BR /&gt;                             do rowB = 1 to MyInputDataGrid_B.row_count() ;&lt;BR /&gt;&lt;BR /&gt;                              /* use the get&lt;TYPE&gt; methods here to retrieve values from each input data grid */&lt;BR /&gt;                             /* use some tmp variables to hold the values from the grid you want to output */&lt;BR /&gt;&lt;BR /&gt;                               MyOutputDataGrid.add_row();&lt;BR /&gt;                               row = row_count();&lt;BR /&gt;&lt;BR /&gt;                               /* if your output isnt String then use set&lt;TYPE&gt; that is appropriate */&lt;BR /&gt;&lt;BR /&gt;                               MyOutputDataGrid.setString('P1',row,tmpA_P1);&lt;BR /&gt;                               MyOutputDataGrid.setString('P2',row,tmpA_P2);&lt;BR /&gt;                               MyOutputDataGrid.setString('P4',row,tmpA_P3);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                               if (m_logger.isDebugEnabled()) then do ;&lt;BR /&gt;                                           m_logger.debug('Added Row number: '||row);&lt;BR /&gt;                               end ;&lt;BR /&gt;&lt;BR /&gt;                               end; /** inner do loop **/&lt;BR /&gt;&lt;BR /&gt;      end; /** do loop **/&lt;BR /&gt;    end; /** execute method **/&lt;BR /&gt;&lt;BR /&gt;endpackage;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/TYPE&gt;&lt;/TYPE&gt;&lt;/TYPE&gt;&lt;/TYPE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 03:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/489122#M995</guid>
      <dc:creator>JamesAnderson</dc:creator>
      <dc:date>2018-08-23T03:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/489273#M996</link>
      <description>&lt;P&gt;Thanks James !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 14:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/489273#M996</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2018-08-23T14:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/491736#M1002</link>
      <description>&lt;P&gt;Hi James,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the Jython code to read two data grids and apply filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ls_out = []&lt;BR /&gt;conf_out = []&lt;BR /&gt;#data = []&lt;BR /&gt;for items in comp_prod_lst:&lt;BR /&gt;&amp;nbsp;if items not in prod_id:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;ind = comp_prod_lst.index(items)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;ls_out += [items]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;conf_out += [conf[ind]]&lt;BR /&gt;filter_prod_cnt = len(ls_out)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bhanu&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/491736#M1002</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2018-08-31T20:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/635193#M1470</link>
      <description>&lt;P&gt;Hi,&lt;SPAN&gt;Bhanu&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use Jython to handle data grids in rtdm,can you provide some examples of Jython operating data grids?I can't find any valid data about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lucifer&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 05:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/635193#M1470</guid>
      <dc:creator>TyrantLucifer</dc:creator>
      <dc:date>2020-03-27T05:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Reading two data grids and apply filter</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/635202#M1471</link>
      <description>Hi Lucifer,&lt;BR /&gt;Some notes and examples below.&lt;BR /&gt;Cheers&lt;BR /&gt;James&lt;BR /&gt;RTDMTable&lt;BR /&gt;The RTDMTable (com.sas.analytics.ph.common.RTDMTable) type corresponds to a datagrid. It has many useful features for manipulation &amp;amp; traversal. It is required to include the EventInfo object on many RTDMTable methods&lt;BR /&gt;&lt;BR /&gt;Create, Write, Read, Delete&lt;BR /&gt;Here are the basic CRUD operations to work with the RTDMTable object from Python. It also illustrates when the builtin EventInfo&lt;BR /&gt;object will also be needed inside your activities (for handling WHERE expressions).&lt;BR /&gt;Example:&lt;BR /&gt;import java.util.Collections as Collections&lt;BR /&gt;import java.lang.Long as Long&lt;BR /&gt;import com.sas.analytics.ph.common.RTDMTable as RTDMTable&lt;BR /&gt;import com.sas.analytics.ph.common.exp.SymbolTable as SymbolTable&lt;BR /&gt;import com.sas.analytics.ph.common.jaxb.DataTypes as DataTypes&lt;BR /&gt;newTable = RTDMTable()&lt;BR /&gt;# Defining columns&lt;BR /&gt;newTable.columnAdd("MY_STRING_COLUMN", DataTypes.STRING, Collections.emptyList());&lt;BR /&gt;newTable.columnAdd("MY_INT_COLUMN", DataTypes.INT, Collections.emptyList());&lt;BR /&gt;# Adding a new row&lt;BR /&gt;newRow = newTable.rowAdd()&lt;BR /&gt;newRow.columnDataSet("MY_STRING_COLUMN", "A String value.")&lt;BR /&gt;newRow.columnDataSet("MY_INT_COLUMN", Long(52));&lt;BR /&gt;# Iterating over the table &amp;amp; reading values&lt;BR /&gt;it = newTable.iterator()&lt;BR /&gt;while it.hasNext():&lt;BR /&gt;row = it.next()&lt;BR /&gt;value = row.columnDataGet("MY_STRING_COLUMN")&lt;BR /&gt;num_value = row.columnDataGet("MY_INT_COLUMN")&lt;BR /&gt;# Deleting all rows with MY_INT_COLUMN greater than 5&lt;BR /&gt;newTable.delete(SymbolTable(), "newTable", eventInfo, "newTable.MY_INT_COLUMN GT 5", None);&lt;BR /&gt;&lt;BR /&gt;SELECT from existing datagrids&lt;BR /&gt;&lt;BR /&gt;To sub-select from an existing datagrid, you use the select() method. The parameters should be familiar to anyone who has used&lt;BR /&gt;the TableSelect function within a calculated variable.&lt;BR /&gt;&lt;BR /&gt;Here is an example:&lt;BR /&gt;("fordCars" is an "Output Variable","cars" is a "Input Variable"):&lt;BR /&gt;&lt;BR /&gt;import com.sas.analytics.ph.common.exp.SymbolTable as SymbolTable&lt;BR /&gt;fordCars=cars.select(SymbolTable(), "myTable", eventInfo, "Model", "myTable.Make EQ 'Ford'", None)&lt;BR /&gt;&lt;BR /&gt;Join Tables&lt;BR /&gt;&lt;BR /&gt;Joining tables is a bit more complicated. RTDM supports only INNER joins between in-memory tables. The syntax should be familiar to those using the TableInnerJoin functionality within calculated items.&lt;BR /&gt;&lt;BR /&gt;Here is an example:&lt;BR /&gt;("joinedTable" is an "Output Variable", "tableA" and "tableB" are "Input Variables")&lt;BR /&gt;&lt;BR /&gt;import com.sas.analytics.ph.common.exp.SymbolTable as SymbolTable&lt;BR /&gt;joinedTable = tableA.innerJoin(&lt;BR /&gt;SymbolTable(),&lt;BR /&gt;"A", # Name for the customer table for use in the columns &amp;amp; WHERE&lt;BR /&gt;tableB, # The right hand side table&lt;BR /&gt;"B", # Name for the right hand side table&lt;BR /&gt;eventInfo, # The event info object (in case of date math)&lt;BR /&gt;"*", # The columns to retain in the joined table, all in this case&lt;BR /&gt;"A.Product_code EQ B.Product_number", # The WHERE clause for the JOIN&lt;BR /&gt;None )&lt;BR /&gt;Sorting&lt;BR /&gt;&lt;BR /&gt;On the RTDMTable object, there is a direct sort method. This sorts the table in place. You can sort on one or more columns.&lt;BR /&gt;Example:&lt;BR /&gt;("inputTable" is an "Input Variable", "outputTable" is an "Output Variable")&lt;BR /&gt;&lt;BR /&gt;inputTable.sort("Color ASCENDING")&lt;BR /&gt;outputTable=inputTable&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Mar 2020 06:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Reading-two-data-grids-and-apply-filter/m-p/635202#M1471</guid>
      <dc:creator>JamesAnderson</dc:creator>
      <dc:date>2020-03-27T06:08:05Z</dc:date>
    </item>
  </channel>
</rss>

