115
Building CLEM Expressions
Calculating Time Passed
Youcan easily calculate the time passed from a bas eline date using a family of functions similar to
the following one. This function retu rns the time in months from the baseline date to the date
represented by the date string DATE as a real number. This is an approximate gure, based on a
month of 30.0 days.
date_in_months(Date)
Comparing Date/Time Values
Valuesof date/time elds can be comp ared across records using functions similar to the following
one. This function returns a value of true if the date stri ngD ATE1represents a date prior to tha t
represented by the date string DATE2. Otherwise, this function returns a value of 0.
date_before(Date1,Date2)
Calculating Differences
Youcan also calculate the difference between two tim es and two dates using functions, such as:
date_weeks_difference(Date1,Date2)
This function returns the time in weeks from the date represented by the date string D ATE1to the
date represented by the date string DATE2 as a real number. This is based on a w eek of 7.0 days. If
DATE2is prior to D ATE1,this fu nction returns a negative number.
Today’sDate
The current date can be added to the data set using the function @TODAY. Today’sdate is added as
a string to the specied eld or new eld using the date format selected in the stream properties
dialog box. For more information, see the topic Date and Time Functions in Chapter 8 on p. 146.
Summarizing Multiple Fields
The CLEM language includes a number of functions that return summary statistics across
multiple elds. These functions may be particularly useful in anal yzing survey data, where
multiple responses to a question may be stored in multiple elds. For more information, see the
topic Workingwit h Multiple-Response Data on p. 117.
Comparison Functions
Youcan compare values across multiple elds using the mi n_n and max_n functions—for example:
max_n(['card1fee''card2fee''card3fee''card4fee'])