Bringing data to a common unit Problem You want to bring to a common unit of measurement numeric data which was collected on different units. Solution There are two possibilities:  if the unit multipliers are integers, assign the multiplier to the unit and perform a multiplication;
 if the unit multipliers are not integers, user the ternary operator in a calculation.
Discussion First, a note of clarification on the actual problem. This recipe discusses the situation where numeric data was collected (e.g., one's weight or one's salary) which requires a numeric value as well as a unit of measurement (e.g., inches vs. centimiters, dollars per hour, per week, per month), typically collected using a unittype question. The questionnaire designer wants to calculate a unique value which will bring all responses to a common unit (e.g., centimiters or dollars per year). If the unit multipliers are integers, it is possible to assign the multiplier as the category code for the unit and to simply multiply this code with the numeric value supplied. For example: SALARY % question What is your salary? % note % categories *998*N*amount *40*per hour *5*per day *1*per week *999*Don't know/no answer % skips % condition % open 998 = N7.2 1 5000 ! ============================================================== PERWEEK CALCUL % question APERWEEK = $SALARY * $ASALARY % note % categories % skips % condition SALARY.EQ.1,5,40 % open 1 = N7.2 1 5000 FORMAT=DOLLAR2 ! ============================================================== If the unit multipliers are not integers (a limitation of answer category codes), use a calculation and the ternary operator (the "implicit if" operator). For example: HEIGHT % question How tall are you? % note % categories *998*N*amount *1*centimeters *2*inches *999*Don't know/no answer % skips % condition % open 998 = N7.2 48 200 ! ============================================================== INCENTIMETERS CALCUL % question AINCENTIMETERS = $AHEIGHT * ( ( $HEIGHT == 1 ) ? 1 : 2.54 ) % note % categories % skips % condition HEIGHT.EQ.1,2 % open 1 = N7.2 48 200 FORMAT=NUM0 ! ==============================================================
email technical support!
