<?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 RTDM: Using Character List output as input parameter to read selected records from a table in SAS Customer Intelligence</title>
    <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/490826#M998</link>
    <description>&lt;P&gt;&lt;BR /&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read the selected products from a input table that has 1 million unique products and I want to pass the other node character list output to use as input to data process(input table).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input table&lt;/P&gt;&lt;P&gt;Prodid, Prodname&lt;/P&gt;&lt;P&gt;1, abc&lt;/P&gt;&lt;P&gt;2, def&lt;/P&gt;&lt;P&gt;3,xyz&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Character list output: [1,3]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to create the data process, criteria variables data type populated by default as per the input table column data type (character in our example). so it expects single input parameter as input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to specify the character list as a type for criteria variables to read multiple values or Is there any way in RTDM to pull selected records from input table by passing list values as input ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bhanu Charan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 13:19:27 GMT</pubDate>
    <dc:creator>bhanucharan</dc:creator>
    <dc:date>2018-08-29T13:19:27Z</dc:date>
    <item>
      <title>RTDM: Using Character List output as input parameter to read selected records from a table</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/490826#M998</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read the selected products from a input table that has 1 million unique products and I want to pass the other node character list output to use as input to data process(input table).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input table&lt;/P&gt;&lt;P&gt;Prodid, Prodname&lt;/P&gt;&lt;P&gt;1, abc&lt;/P&gt;&lt;P&gt;2, def&lt;/P&gt;&lt;P&gt;3,xyz&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Character list output: [1,3]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to create the data process, criteria variables data type populated by default as per the input table column data type (character in our example). so it expects single input parameter as input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to specify the character list as a type for criteria variables to read multiple values or Is there any way in RTDM to pull selected records from input table by passing list values as input ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bhanu Charan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 13:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/490826#M998</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2018-08-29T13:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Using Character List output as input parameter to read selected records from a table</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491483#M1000</link>
      <description>Hi Bhanu,&lt;BR /&gt;The Data Process does not support mapping List type variables as an input to a criteria variable. To achieve what you want you would need to create a SAS process using DS2 code (or using Groovy or Jython), to accept a List and then translate that into a IN clause in the SQL query.&lt;BR /&gt;Your first query that retrieves the initial list is OK, then downstream from it add a Process Node.&lt;BR /&gt;An example of the type of DS2 code you would need is below. Note the FedServer only supports 16 values in an IN Clause. This code essentially loops through the String List, and builds the IN Clause with the values from the list. It returns a flag to indicate if the customer has one or more of the input products, you can modify this for your needs.&lt;BR /&gt;HTH,&lt;BR /&gt;James&lt;BR /&gt;package CheckCustomerProducts / overwrite=yes;&lt;BR /&gt;&lt;BR /&gt;   /** This package will support up to 16 values for the IN CLAUSE. **/&lt;BR /&gt;   /** FedServer throws a SQL prepare error if more than 16 parameters are passed in the IN clause **/&lt;BR /&gt;   /** If the products list contains &amp;gt; 16 items, only the first 16 are used. The remainder will be ignored  **/&lt;BR /&gt;&lt;BR /&gt;        dcl package tap_logger m_logger();&lt;BR /&gt;        dcl package sqlstmt m_sqlstatement('select CustomerID, prod_nm from {Catalog}.{Schema}.{SomeTable} where CustomerID = ? AND prod_nm IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)') ;&lt;BR /&gt;&lt;BR /&gt;        method execute( double CustomerID,&lt;BR /&gt;                        package tap_string_array products,&lt;BR /&gt;                        in_out Integer HasProducts);&lt;BR /&gt;&lt;BR /&gt;            dcl int i size rc ;&lt;BR /&gt;&lt;BR /&gt;            dcl int param_num ;&lt;BR /&gt;            dcl int m_maxBind;&lt;BR /&gt;            dcl double startDTTM endDTTM elapsedTime;&lt;BR /&gt;&lt;BR /&gt;            m_maxBind = 16 ;&lt;BR /&gt;&lt;BR /&gt;            if (m_logger.isDebugEnabled()) then&lt;BR /&gt;               do;&lt;BR /&gt;                  startDTTM=datetime() ;&lt;BR /&gt;                  m_logger.debug(catt('CheckCustomerProducts: Entered execute method for CustomerID: ',CustomerID));&lt;BR /&gt;               end ;&lt;BR /&gt;&lt;BR /&gt;            size = products.size();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;            if size &amp;gt; 0 then&lt;BR /&gt;                do;&lt;BR /&gt;                    if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                       do ;&lt;BR /&gt;                           if (size &amp;gt; m_maxBind) then&lt;BR /&gt;                              m_logger.debug('CheckCustomerProducts: Product list has '||size||' items. Only the first '||m_maxBind||' values will be used.');&lt;BR /&gt;                           else&lt;BR /&gt;                              m_logger.debug('CheckCustomerProducts: Product list has '||size||' items.');&lt;BR /&gt;                       end ;&lt;BR /&gt;&lt;BR /&gt;                    m_sqlstatement.setdouble(1,CustomerID);&lt;BR /&gt;&lt;BR /&gt;                    param_num = 1 ;&lt;BR /&gt;&lt;BR /&gt;                    /** Set parameters from list up to the value of m_maxBind or size of list **/&lt;BR /&gt;                    do while (param_num &amp;lt;= size and param_num &amp;lt;= m_maxBind) ;&lt;BR /&gt;                        m_sqlstatement.setchar(1+param_num, products.get(param_num));&lt;BR /&gt;                        param_num = param_num + 1 ;&lt;BR /&gt;                    end ;&lt;BR /&gt;&lt;BR /&gt;                    /** If size is smaller than m_maxBind, fill remaining parameters with last value in list **/&lt;BR /&gt;                    do while (param_num &amp;lt;= m_maxBind) ;&lt;BR /&gt;                        m_sqlstatement.setchar(1+param_num, products.get(size));&lt;BR /&gt;                        param_num = param_num + 1 ;&lt;BR /&gt;                    end ;&lt;BR /&gt;&lt;BR /&gt;                    m_sqlstatement.execute();&lt;BR /&gt;                    rc = m_sqlstatement.fetch();&lt;BR /&gt;&lt;BR /&gt;                    if rc = 0 then&lt;BR /&gt;                        do;&lt;BR /&gt;                            /* successful fetch therefore has products*/&lt;BR /&gt;                            HasProducts = 1;&lt;BR /&gt;&lt;BR /&gt;                            if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                                m_logger.debug('CheckCustomerProducts: FETCH returned records therefore HasProducts = '||HasProducts);&lt;BR /&gt;                        end;&lt;BR /&gt;                    else if rc = 1 then&lt;BR /&gt;                        do;&lt;BR /&gt;                            /* ERROR unsuccessful fetch therefore has NO products*/&lt;BR /&gt;                            HasProducts = 0;&lt;BR /&gt;&lt;BR /&gt;                            if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                                m_logger.debug('CheckCustomerProducts: FETCH returned ERROR therefore HasProducts = '||HasProducts);&lt;BR /&gt;                        end;&lt;BR /&gt;                    else if rc = 2 then&lt;BR /&gt;                        do;&lt;BR /&gt;                            /* NODATA therefore has NO products*/&lt;BR /&gt;                            HasProducts = 0;&lt;BR /&gt;&lt;BR /&gt;                            if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                                m_logger.debug('CheckCustomerProducts: FETCH returned NODATA therefore HasProducts = '||HasProducts);&lt;BR /&gt;                        end;&lt;BR /&gt;                end;&lt;BR /&gt;            else&lt;BR /&gt;                do;&lt;BR /&gt;                    HasProducts=0;&lt;BR /&gt;&lt;BR /&gt;                    if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                       do ;&lt;BR /&gt;                          endDTTM = datetime() ;&lt;BR /&gt;                          elapsedTime=endDTTM - startDTTM ;&lt;BR /&gt;                          m_logger.debug('CheckCustomerProducts: No Products to search for provided. Exiting DS2 process');&lt;BR /&gt;                       end ;&lt;BR /&gt;                end;&lt;BR /&gt;&lt;BR /&gt;                if (m_logger.isDebugEnabled()) then&lt;BR /&gt;                  do ;&lt;BR /&gt;                     endDTTM = datetime() ;&lt;BR /&gt;                     elapsedTime=endDTTM - startDTTM ;&lt;BR /&gt;                     m_logger.debug('CheckCustomerProducts: Execution time for CustomerID '||CustomerID|| ' is '||left(put(elapsedTime*1000, COMMA6.2))||'ms.');&lt;BR /&gt;                  end ;&lt;BR /&gt;        end; /** execute method **/&lt;BR /&gt;&lt;BR /&gt;    endpackage;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Aug 2018 01:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491483#M1000</guid>
      <dc:creator>JamesAnderson</dc:creator>
      <dc:date>2018-08-31T01:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Using Character List output as input parameter to read selected records from a table</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491734#M1001</link>
      <description>&lt;P&gt;Hi James,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In our data Some of the products have more than 16 values. I have tried Jython to read cdm data(Postgres). Below is the sample code to fetch the data using sample sql into RTDM using process node. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import os&lt;BR /&gt;print(os.system("hostname"))&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;import psycopg2&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;productlist =[]&lt;BR /&gt;data = []&lt;BR /&gt;pg_conn = psycopg2.connect(database="postgres", user="xxxxxx", password="xxxxxxxxx", host="postgresdb", port=5432)&lt;BR /&gt;pg_cur = pg_conn.cursor()&lt;BR /&gt;pg_cur.execute("SELECT productid FROM cdm.table limit 10")&lt;BR /&gt;data = pg_cur.fetchall()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above code is working fine when I submit the same in Mid tier server (cli). When I execute the campaign I am getting the below error&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ImportError: No module named _psycopg&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added the _pyscopg package in jython jar file as well and tried the below code to install _psycopg package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import os&lt;BR /&gt;print(os.system("hostname"))&lt;BR /&gt;import subprocess&lt;BR /&gt;import sys&lt;/P&gt;&lt;P&gt;def install(package):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; subprocess.call([sys.executable, "-m", "pip", "install", psycopg2])&lt;BR /&gt;print("Done Install") /* code is executing till this point*/&lt;BR /&gt;&lt;STRONG&gt;import psycopg2&lt;/STRONG&gt; /* throwing error */&lt;BR /&gt;print("Imported Package Install")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couldn't find a detailed logs in sasserver6_1,sasserver7_1. It is writing print statements in catalina logs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491734#M1001</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2018-08-31T20:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: RTDM: Using Character List output as input parameter to read selected records from a table</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491963#M1003</link>
      <description>HI Bhanu,&lt;BR /&gt;Im not familiar with Python, however its important to note that for RTDM we are using Jython. To extend this with pure-Python packages you can append to the Jython module search paths with the following -D option (for SASServer7): -Dcom.sas.analytics.crm.rtdm.pythonPaths={Paths to your python modules and code}&lt;BR /&gt;Regards&lt;BR /&gt;James&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Sep 2018 02:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/RTDM-Using-Character-List-output-as-input-parameter-to-read/m-p/491963#M1003</guid>
      <dc:creator>JamesAnderson</dc:creator>
      <dc:date>2018-09-03T02:41:31Z</dc:date>
    </item>
  </channel>
</rss>

