BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cristian_SAS
Calcite | Level 5

Hi community...

I need to resolve this very quickly.

I established an extended table for CONTACT_HISTORY table of Customer Intelligence Common Data Model. I want to update a variable, this is LAST_CONTACT_DT.

HERE IS THE EXTENDED TABLE:

CELL_PACKAGE_SK     NUMBER(10) NOT NULL ,

CAMPAIGN_CD NVARCHAR2(30) NOT NULL,

CUSTOMER_ID         NUMBER(10) NOT NULL ,

LAST_CONTACT_DT DATE NOT NULL,

CICLO_ID NVARCHAR2(2) NOT NULL,

END_MANAGEMENT_DT DATE NOT NULL

For each occurrence for every communication for some campaign, if the Customer exist, i need to update the value of the variable.

First, I try this...

PROC SQL;

  UPDATE LIB.CI_CONTACT_HISTORY_C_EXTENDED SET LAST_CONTACT_DT = &FECHA. WHERE CUSTOMER_ID IN (SELECT CUSTOMER_ID FROM EXIST);

QUIT;

That code, update the value for each Customer in the table, but for each campaign (CAMPAIGN_CD) that the customer exist. I only need to update the variable which contain the same END_MANAGEMENT_DT f the campaign that is being processed .. so.. I posed the following:

PROC SQL;

UPDATE LIB.CI_CONTACT_HISTORY_C_EXTENDED SET LAST_CONTACT_DT = &FECHA.

FROM LIB.CI_CONTACT_HISTORY_C_EXTENDED

     INNER JOIN WORK.EXIST EXISTS

  ON EXTENDED.CUSTOMER_ID = EXISTS.CUSTOMER_ID AND

  DATEPART(EXTENDED.END_MANAGEMENT_DT) = EXISTS.CONTACT_DT;

QUIT; /*The datepart function is required. WORK is SAS Code and the extended table is ORACLE Schema.*/

But this, doesn´t work.

Has anybody knows how to do that? How to realice an update from inner join between this tables: which contains the Customers in the occurrence of the communication and the table which contains that customers for the last occurrence of the previous communication.

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

PROC SQL;

  UPDATE LIB.CI_CONTACT_HISTORY_C_EXTENDED T1 SET LAST_CONTACT_DT = &FECHA.

  WHERE EXISTS (SELECT * FROM EXIST WHERE CUSTOMER_ID=T1.CUSTOMER_ID AND CONTACT_DT  = DATEPART(T1.END_MANAGEMENT_DT));

QUIT;

View solution in original post

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

PROC SQL;

  UPDATE LIB.CI_CONTACT_HISTORY_C_EXTENDED T1 SET LAST_CONTACT_DT = &FECHA.

  WHERE EXISTS (SELECT * FROM EXIST WHERE CUSTOMER_ID=T1.CUSTOMER_ID AND CONTACT_DT  = DATEPART(T1.END_MANAGEMENT_DT));

QUIT;

Cristian_SAS
Calcite | Level 5

Excelente... Muchas Gracias por el aporte...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 406 views
  • 0 likes
  • 2 in conversation