BookmarkSubscribeRSS Feed
Will_F_SAS
SAS Employee

thumbnail.png

 

 

 

 

 

In SAS Customer Intelligence 360, merge tags play an important role in personalizing email content for each of your customers. SAS has started rolling out an enhancement to merge tags that makes them data-type aware.

 

When data-type awareness is enabled, the processing of conditional merge tags can consider the data type for the data items that you specify in the merge tag’s conditional test. This feature enables you to define conditional merge tags that are more precise.

 

Note: SAS is rolling this feature out to customers in phases, and it is not currently enabled by default. If you would like more information, contact your SAS Global Customer Success (GCS) manager.

 

In this document:

  1. About Storing Customer Data
  2. About Inserting Merge Tags
  3. Merge Tags Before Data-Type Awareness
  4. Merge Tags After Data-Type Awareness
  5. Verify Data Before Enabling Data-Type Awareness
  6. Testing Data-Type Awareness with Responsive Previews
  7. Examples

 

About Storing Customer Data

Customer data can be stored in a customer data table in SAS Customer Intelligence 360 or in a database that is on-premises.

 

When you store customer data in SAS Customer Intelligence 360, you upload the data to a corresponding table in the system. Tables are defined in General Settings > Data Collection > Table Management, and each table defines the structure for a set of customer data. Table definitions contain data items (columns), which specify the data type for that column and how the data is used by SAS Customer Intelligence 360.

 

For example, you want to store a login ID, email address, and the age for your customers. The table’s definition would have three data items (which become columns in the actual table):

  • a STRING data item for login ID
  • a STRING data item for the email address
  • an INT (or SMALLINT) data item for the age

 

When you store data in an on-premises database, the database contains information about the data type for each column of data. The data values and data type are forwarded to SAS Customer Intelligence 360 when you use that data in a task.

 

About Inserting Merge Tags

You can use merge tags to add conditions to your email content based on stored customer data or data that is collected from a trigger event. For example, you might want to offer a discount based on a customer’s age.

 

The following image shows conditional logic for a discount that is based on an age range. Recipients that are over 40 years old get a 15% discount, and recipients that are over 25 years old get a 25% discount:

 01.png

 

Note: These conditions are tested in order. If a recipient matches the first condition, the second condition is not tested.

 

 

You can also set a default value for the merge tag, which is used when neither condition matches. The following screen shot shows a default discount of 30% when a recipient does not match the tested conditions (in this case, they are under 25 years old).

 

02.png

 

The final, raw text for the merge tag is this:

 

{{@@DATAHUB.sample_customer_data.age>40##15%@@@@DATAHUB.sample_customer_data.age>25##25%@@||30%}}

 

The structure of the merge tag is based on the data’s source, which includes these parts:

  • the root system, which is cloud storage versus an on-premises system
  • the table’s name
  • the name of the data item (column) for the specific piece of data

 

In the example above, the source data is coming from a customer table in SAS Customer Intelligence 360. So, the merge tag uses this format for the data’s source:

DATAHUB.<table name>.<data item>

 

To contrast, when the source data is coming from an on-premises system, the merge tag uses this format for the data’s source:

ONPREM.root.<data item>

 

Merge Tags Before Data-Type Awareness

If data-type awareness is not enabled, customer’s data still has a data type assigned to each item, but conditional logic for merge tags cannot take advantage of those types when it makes comparisons.

 

Without data-type awareness, the conditional logic converts everything to a STRING type, and then performs the logical comparison based on alphanumeric ordering and string length.

 

Example of Merge-Tag Logic without Data-Type Awareness

For example, recall one section of the merge tag that was created earlier for the customer discounts:

DATAHUB.sample_customer_data.age>40

 

When a customer’s age (DATAHUB.sample_customer_data.age) is 33, this is what happens in the system without data-type awareness:

  1. The number 33 is converted to the string “33”.
  2. The comparison value in the merge tag (40) is converted to the string “40”.
  3. The system uses the specified operator to test whether the string “33” is greater than the string “40”.

 

For alphanumeric comparisons, the Boolean operators (>, >=, =, and so on) work based on lexicographic order.

 

Here are some more examples:

Test

Result

“aaa” < “aaaa”

TRUE

“33” > “23”

TRUE

“doghouse” > “Doghouse”

TRUE (because “d” is greater than “D”)

 

Fortunately, in most situations this logic gives the expected result. However, in some situations you might get a result that is unexpected. For example:

 

Test

Result

“33” > “300”

TRUE

 

The result is TRUE, because – by lexicographic order – the string “33” is greater than the string “300”.

 

Merge Tags After Data-Type Awareness

When data-type awareness is enabled, SAS Customer Intelligence 360 takes data types into account when doing logical comparisons.

 

In the user interface, the data type is indicated by an icon for each data item. In the following screen shot, Age is a numeric type and Email Address is a string:

 

03.png

 

 

The conditional logic in merge tags can test these values based on their actual data type, rather than testing their STRING variants.

 

Note: Data-type awareness is only used for data that is stored in the data hub or an on-premises system, because the data type can be explicitly defined. In contrast, real-time data from trigger events, for example, are never assigned an explicit data type (due to JavaScript’s type-less design). These values are still compared lexicographically as strings.

 

For example, assume the merge tag uses the earlier discount offer that is based on the customer’s age. Part of the merge tag is this value:

DATAHUB.sample_customer_data.age>40

 

When the customer’s age (DATAHUB.sample_customer_data.age) is 33, the system uses numeric comparison to reach the result: 33 > 40 evaluates to FALSE.

 

Here are more details about how different data types are used:

  • When you compare Date types and Timestamp types (or DateTime types), only the date portion of the Timestamp item is used in a comparison.
  • Timestamps or DateTime items are time-zone aware, and these items are displayed with a time zone offset (such as -4:00 GMT).
  • All sizes of integers (for example, SMALLINT or INT types) are converted to an integer type with up to 50 significant digits.
  • If a floating-point number is compared to a double, the numbers are converted to a floating-point equivalent with up to 50 significant digits.
  • If an integer and a double are compared, the integer is converted to a floating-point number with up to 50 significant digits.

 

For examples and more information about how data-type awareness affects display text and conditions, see Examples.

 

Verify Data Before Enabling Data-Type Awareness

Data-type awareness provides more flexibility when defining new merge tags. In most situations, enabling this feature should not affect your existing merge tags.

 

As a best practice, you should review your table definitions (data descriptors) and the corresponding customer data before SAS enables data-type awareness.

 

Ensure that each data item is assigned the correct data type. For example:

  • Date values should use either DATE or TIMESTAMP, depending on their format.
  • Numbers should use the appropriate type: INT, SMALLINT, or DOUBLE.
  • The STRING data type should be used for values that you want to store as strings.

 

You might need to update your table definition and reimport data to reflect the correct data types.

 

Testing Data-Type Awareness with Responsive Previews

After data-type awareness is enabled, you can use responsive previews to verify that your output and conditional logic is working as expected.

 

There are some things to be aware of when you are testing with responsive previews:

  • For triggered email tasks that rely on a trigger event’s attribute, you must configure the trigger event if you want data to display in a responsive preview.
  • For bulk email tasks that rely on a transient file for merge tag values, you must select the transient file in the task’s targeting to display this in the responsive preview.

 

Examples

Data-Type Awareness for Display Formats

This table shows examples of how data types are displayed when data-type awareness is disabled versus when it is enabled.

 

Data Type

Value

Original Display

Type-Aware Display

STRING

“Some Text”

Some Text

Some Text 0

STRING

“27502”

27,502

27502 

INTEGER

123456

123,456

123,456 (US)
123.456 (DE+)

123 456 (FR)

DOUBLE (floating point)

123.456

123.456

123.456 (US)
123,456 (EU)

DATE

2021-02-05

2021-02-05

2021-02-05

DATE

Feb 2, 2021

Feb 2, 2021

2021-02-05

DATE

0-0-0

0-0-0

<Current date>1

DATE (US Locale)

2/3

2/3

2021-02-031

DATE (DE Locale)

2/3

2/3

2021-03-021

TIMESTAMP

0/0/0 0:0:0

0/0/0 0:0:0

<Current date> 00:00:00 1 GMT-4 3

TIMESTAMP

0/0/0

0/0/0

<Current date>1 <Current time> 2

TIMESTAMP (US Locale)

Feb 3, 2019  8:00

Feb 3, 2019  8:00

2019-02-03 8:00:00 GMT-4 3

TIMESTAMP (DE Locale)

3/2/2019  8:00

3/2/2019  8:00

2019-02-03 8:00:00 GMT+2 3

 

0 – No change from original display

1Zero values are replaced with the current value of the year, month, or day

2Missing values are replaced with current value of year, month, day, hour, minute, or second

3The system time zone is used if a time zone is not present in the input data.

 

TIP: If you want to inject the raw values for any data type (with no formatting applied), you can use a $ character in the merge tag. For example, this merge tag displays a date in the original format from your source:

%%$DATAHUB.cust.birthday%%

 

Data-Type Awareness in Conditionals

In general, when a type-aware merge tag is compared to a string — which are used in conditional merge tags or conditional blocks — the system attempts to convert the string to the merge tag’s data type before making a comparison.

 

Note: One consequence of this type conversion is the loss of precision if you compare an INTEGER data value to a string with a decimal value. In this situation, the integer data from the merge tag is compared only to the integer portion of the string. The string’s value beyond the decimal point is not included.

 

If the string cannot be converted to the merge tag’s data type, the data for the merge tag is converted to a string and then compared to the original string from the conditional text.

 

For localization, the system can parse these parts of the data for comparison and display purposes:

  • localized values for AM and PM
  • month abbreviations and their full-length English equivalents
  • localized decimal point and grouping characters

 

Example 1 – Doubles and Floating-point Numbers

This is the value for a sample merge tag:

Merge tag: %%DATAHUB.cust.float%%

Type: DOUBLE

Value: 123.000

 

These are examples of how this merge tag is used in conditional processing:

 

Conditional Merge Tag

Result

@@DATAHUB.cust.float=123.000##True||False@@

True

@@DATAHUB.cust.float=123##True||False@@

True

@@DATAHUB.cust.float=00,123.00000##True||False@@

True

@@DATAHUB.cust.float=0123.000000001##True||False@@

False

 

Example 2 – Integers

This is the value for a sample merge tag:

Merge tag: %%DATAHUB.cust.int%%

Type: INTEGER

Value: 1234

 

These are examples of how this merge tag is used in conditional processing:

 

Conditional Merge Tag

Result

@@DATAHUB.cust.int=1234.567##True||False@@

True

@@DATAHUB.cust.int=1,234##True||False@@

True

@@DATAHUB.cust.int=001,234##True||False@@

True

@@DATAHUB.cust.int=-1,234##True||False@@

False

 

Example 3 – Dates

This is the value for a sample merge tag:

Merge tag: %%DATAHUB.cust.date%%

Type: DATE

Value: May 12, 2020

 

These are examples of how this merge tag is used in conditional processing:

 

Conditional Merge Tag

Result

@@DATAHUB.cust.date=5/12/2020##True||False@@

True (if the US locale)

@@DATAHUB.cust.date=5/12/2020##True||False@@

False (for non-US locales)

@@DATAHUB.cust.date=Dec 5,2020##True||False@@

True (for non-US locales)

@@DATAHUB.cust.date=May 12,2020 12:30:00 ##True||False@@

True (the time part of the string is ignored)

@@DATAHUB.cust.date=May 12##True||False@@

False (the missing parts use the current date)

 

Example 4 – Timestamps

This is the value for a sample merge tag:

Merge tag: %%DATAHUB.cust.datetime%%

Type: TIMESTAMP

Value: Apr 5, 2015  13:10:00 GMT-4

 

These are examples of how this merge tag is used in conditional processing:

 

Conditional Merge Tag

Result

@@DATAHUB.cust.date=4/5/2015 1:10 PM##True||False@@

True (for the US locale)

@@DATAHUB.cust.date=5/4/2015 5:10 PM GMT##True||False@@

True (for non-US locales)

@@DATAHUB.cust.date=Apr 5, 2015##True||False@@

True (only the dates are compared)

@@DATAHUB.cust.date=2015-4-5##True||False@@

True (only the dates are compared)

 

How to improve email deliverability

SAS' Peter Ansbacher shows you how to use the dashboard in SAS Customer Intelligence 360 for better results.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 1216 views
  • 10 likes
  • 1 in conversation