Skip to Content
Author's profile photo Andreas Forster

Custom R Component – String Generator (Random and Unique)

When running direct Marketing campaigns you may want to include personalised coupons/tokens. These have to be random (so that they cannot be guessed) and unique (so you know who is using the coupon). This component enables SAP Predictive Analytics, Expert Mode to create such random and unique tokens. It is not directly predictive functionality, but it can come in handy as part of executing a Marketing activity.



Please note that this component is not an official release by SAP and that it is provided as-is without any guarantee or support. Please test the component to ensure it works for your purposes.


No specific prerequisites. You can use the component on any dataset.


Please let me know should you encounter any limitations.


These parameters can be set by the user.

Parameter Description
String Length

Length of the random string, with the range of 3 to 50 characters.

Output column added by this component

Column Description

Random but unique string consisting of upper case letters from A to Z and numbers from 0 to 9. In case the possible combinations of characters is less than double the requested number of random strings, the output will be NA. Ensure the chosen string length is large enough to avoid this.

How to Implement

The component can be downloaded as .spar file from GitHub. Then deploy it as described here. You just need to import it through the option “Import/Model Component”, which you will find by clicking on the plus-sign at the bottom of the list of the available algorithms.


You can try this component on the dataset MarketingTargetList.csv, which is a subset of the Census01.csv file that comes with SAP Predictive Analytics.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.