Hello All,
I am trying to develop a new decision on SAS VIYA ID interface. There are several database tables on teredata. This tables inculudes the some available offers for each customers and I have to assign one offers to one customer randomly. This campaing works weekly. The first 3 offers can not given as new offer to customer next week. How I do that case on ID? How I will made a connection with database? Must it be on python file this all process including connection to db, conditions etc. ? I really appriciated if you guide me.
Hi, you can use that code I shared below. First of all, you should connect to DB and query to your caslib.
def execute():
'Output: customer_id'
import teradatasql
try:
conn = teradatasql.connect(
host='<host_name>',
user='<username>',
password='<password>',
database='<your_DB>'
)
cursor = conn.cursor()
cursor.execute("SELECT TOP 1 customer_id FROM <your_DB>.CUSTOMER")
row = cursor.fetchall()
cursor.close()
conn.close()
return row
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.