BookmarkSubscribeRSS Feed
AliZiya
Obsidian | Level 7

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. 

1 REPLY 1
onuroruc
Fluorite | Level 6

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 277 views
  • 1 like
  • 2 in conversation