0 / 0
Conversion functions
Last updated: Oct 09, 2024
Conversion functions (SPSS Modeler)

With conversion functions, you can construct new fields and convert the storage type of existing files.

For example, you can form new strings by joining strings together or by taking strings apart. To join two strings, use the operator ><. For example, if the field Site has the value "BRAMLEY", then "xx" >< Site returns "xxBRAMLEY". The result of >< is always a string, even if the arguments aren't strings. Thus, if field V1 is 3 and field V2 is 5, then V1 >< V2 returns "35" (a string, not a number).

Conversion functions (and any other functions that require a specific type of input, such as a date or time value) depend on the current formats specified in the flow properties. For example, if you want to convert a string field with values Jan 2021, Feb 2021, and so on, select the matching date format MON YYYY as the default date format for the flow.

Table 1. CLEM conversion functions
Function Result Description
ITEM1 >< ITEM2 String Concatenates values for two fields and returns the resulting string as ITEM1ITEM2.
to_integer(ITEM) Integer Converts the storage of the specified field to an integer.
to_real(ITEM) Real Converts the storage of the specified field to a real.
to_number(ITEM) Number Converts the storage of the specified field to a number.
to_string(ITEM) String Converts the storage of the specified field to a string. When a real is converted to string using this function, it returns a value with 6 digits after the radix point.
to_time(ITEM) Time Converts the storage of the specified field to a time.
to_date(ITEM) Date Converts the storage of the specified field to a date.
to_timestamp(ITEM) Timestamp Converts the storage of the specified field to a timestamp.
to_datetime(ITEM) Datetime Converts the storage of the specified field to a date, time, or timestamp value.
datetime_date(ITEM) Date Returns the date value for a number, string, or timestamp. Note this is the only function that allows you to convert a number (in seconds) back to a date. If ITEM is a string, creates a date by parsing a string in the current date format. The date format specified in the flow properties must be correct for this function to be successful. If ITEM is a number, it's interpreted as a number of seconds since the base date (or epoch). Fractions of a day are truncated. If ITEM is a timestamp, the date part of the timestamp is returned. If ITEM is a date, it's returned unchanged.
stb_centroid_latitude(ITEM) Integer Returns an integer value for latitude corresponding to centroid of the geohash argument.
stb_centroid_longitude(ITEM) Integer Returns an integer value for longitude corresponding to centroid of the geohash argument.
to_geohash(ITEM) String Returns the geohashed string corresponding to the latitude and longitude using the specified number of bits for the density. A geohash is a code used to identify a set of geographic coordinates based on the latitude and longitude details. The three parameters for to_geohash are:
  • latitude: Range (-180, 180), and units are degrees in the WGS84 coordinate system
  • longitude: Range (-90, 90), and units are degrees in the WGS84 coordinate system
  • bits: The number of bits to use to store the hash. Range [1,75]. This affects both the length of the returned string (1 character is used for every 5 bits), and the accuracy of the hash. For example, 5 bits (1 character) represents approximately 2500 kilometers, or 45 bits (9 characters), represents approximately 2.3 meters.
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more