The pad function returns the values of the column filled (padded) with the padstring value to reach the specified length. The string can be added at the beginning (where = "begin" or by default) or at the end (where = "end") of the string, according to the value of the parameter where.
pad(column, len, value, where)
If you are using continuous attributes, check the Flow Execution Parameters.
The nominal attribute used to compute the text lengths. If it is not nominal, it will be casted to nominal upon function’s computation. The column parameter is mandatory.
The length (number of letters) of the resulting words. The len parameter is mandatory.
The padstring to be added to fill the desired length, if the original word is shorter than the len. It is set to 0 as default. If the padstring is not nominal, it will be casted to nominal upon function’s computation.
It controls the position where the padstring is added. If it is ‘begin’, the padstrings will be added at the beginning of the word, while if it is ‘end’, the padstrings will be added at the end.
The following example uses the E-commerce shipping data dataset.
In this example, we want the ID attribute values to have the same length, which is 6 for administrative reasons.
Add a new attribute, called newID and type the following formula:
As we didn’t specify any value parameters, 0 is added to reach the len.
As we didn’t specify any where parameters, the values are added at the beginning of the word.
If we want to add specific values ( x ) at the end of the ID attribute’s strings, we need to add the value and where parameters to the function. The function becomes: