Dear Users I thought this tip might be useful for those who use Phoenix built in data tranformations.
I searched the forums and could not find something similar.
In this example I illustrate how to use the & operator in a custom transformation with nested if statements applied to coding an Occasion variable.
Suppose you have a variable here agemonths ranging from 0 to 25.
You want to cut it into intervals of three months each. We can call this equal width binning. It might be useful for graphical purposes or for occasion modeling or something else !
Here is how to write your cutom transformation note that I named the intervals 1 ,2,3 etc. you might want to recode to the middle of the bin or something else.
if( (agemonths< 3 ) ,1,
if( ( (agemonths>=3 ) & (agemonths <6 ) ),2,
if( ( (agemonths>=6 ) & (agemonths <9 ) ),3,
if( ( (agemonths>=9 ) & (agemonths <12) ),4,
if( ( (agemonths>=12) & (agemonths <15) ),5,
if( ( (agemonths>=15) & (agemonths <18) ),6,
if( ( (agemonths>=18) & (agemonths <21) ),7,
if( ( (agemonths>=21) & (agemonths <24) ),8,
it is very important to have each condition in parentheses:
(agemonths>=3 ) & (agemonths <6 )
and then an outer parentheses:
( (agemonths>=3 ) & (agemonths <6 ) )
for each condition.
Hope this help.