Syntax Guide

Syntax Guide: Filtered Answer Options

For categorical single select and multi-select questions, Survey Solutions allows you to filter the answer options so that not all the answer options for the question will be displayed to the interviewer. Filtering answer options can help improve data quality so that an interviewer cannot select answer options that are either impossible or highly unlikely. For example, for a question where the interviewer has to select the household member’s father, you can filter the answer options so that anyone that is younger than the household member will not be displayed.

December 2, 2016

Syntax Guide: Multi-select questions

Two types of multi-select questions There are two types of multi-select questions. They differ not only in the way they appear, but in the way their answers can be referenced with Survey Solutions’ conditions language. Click below on the type of multi-select question that interests you: Series of tick boxes Series of yes/no questions Series of tick boxes Technical introduction When the interviewer answers a multi-select question, the answers are stored in an array.

November 30, 2016

Syntax Guide: List questions

List questions are recorded as Tuple<decimal, string> data type. Each item in a list question response consists of two elements. One is the item number, and the other is the accompanying text. For example, in the list question displayed. “Paul Smith” is the text element (Item2) and “2” is the number(Item1). List of household members = [ {1, “Mary Smith”} {2, “Paul Smith”} {3, “Richard Smith”} ]  The following functions can be used in conditions for list questions:

November 28, 2016

Syntax Guide: Text questions

Responses to text questions are recorded as a string data type. The content for these types of questions consists of characters (e.g. the letter “A”), group of characters (e.g. “Mat”), or class of characters (e.g. white or empty space). The following functions can be used in conditions for text questions: Length: Checks the number of characters “A text”: Checks that the response is exactly equal to a specified text (“A text”) Contains: Checks that the response includes a specified text ConsistsOf: Checks that the response includes one or more of the specified characters IsAlphaLatin: Checks that the response consists of latin characters IsAlphaLatinOrDelimiter: Checks that the response consists of latin characters and delimiters IsNullOrWhiteSpace: Checks that the response is null or consists of blank spaces  Length  Description Checks the number of characters.

November 28, 2016

Syntax Guide: Barcode questions

Responses for barcode questions are recorded as a string data type. The following functions can be used in conditions for barcode questions: Length: Checks the number of characters StartsWith: Checks that the barcode starts with specific characters EndsWith: Checks that the barcode ends with specific characters IsNumber: Checks that the barcode is a number ConsistsOf: Checks that the barcode consists of a specific set characters  Length Description Checks the number of characters.

November 28, 2016

Syntax Guide: GPS questions

Responses for the GPS questions are recorded as: class { double Latitude; double Longitude; double Accuracy; double Altitude; } The following functions can be used in conditions for GPS questions: Longitude, Latitude, Accuracy, and Altitude. Retrieves the latitude/longitude/accuracy/altitude of a GPS coordinate. InRectangle. *Check if the coordinates are inside a rectangle.*  GpsDistance. Calculate the distance between two coordinates in meters. GpsDistanceKm. Calculate the distance between two coordinates in kilometers.

November 22, 2016

Syntax Guide: Date questions

There are two types of date questions: Calendar and Current time. Both of these questions are recorded as DateTime? data type. Responses for the calendar data questions are recorded as {Year, Month, Day}. Meanwhile, responses to the current time questions are recorded as {Year, Month, Day, Hour, Minute, Second}. Calendar Comparisons Relational Operators. Less than, greater than, equal to, etc InRange. Checks if the date falls within an interval.

November 19, 2016

Syntax Guide: Single-select questions

Common tasks The section below lists the common tasks, and the elements of the syntax for accomplishing them. Comparison to a value Relational Operators less than, greater than, equal to, etc. Comparison to a range InRange. Checks if the selected answer falls within a range of user-specified values. Comparison to a list of values InList. Checks whether the selected answer is among the set of enumerated values.

November 17, 2016

Syntax Guide: Numeric Questions

Responses to numeric questions are recorded in the long data type for integer numbers and record in the double data type for real numbers (ie 1.5, 2.73, 15.25, 2.0). The following functions and operators can be used in conditions for numeric questions: Comparison to a value Relational Operators: less than, greater than, equal to, etc  Comparison to a range or several values   InRange: Checks if the number falls within a range InList: Checks if the number falls within a list of numbers  Math Functions These are the functions in the C# Math Class that could be useful in your instrument:

August 18, 2016

Syntax Guide: Using LINQ Expressions for Conditions in Rosters

Rosters are common survey instruments (ie household roster, assets roster, food consumption roster). Using Language Integrated Query (LINQ) and lambda expressions in the C# language, we are able to code enabling and validation conditions for rosters that can both: Horizontally: Refer to the values of other variables for the current occurrence Vertically: Refer to the values of the same variable for other items in the roster In this article, we will cover the general syntax, common operators, provide a few examples on how to write enabling and validation conditions for rosters.

November 21, 2016

Syntax Guide: System Generated Variables

These are variables that are created by Designer to allow the user to refer to certain variables or lines in a roster in enabling conditions or validation conditions. More detail is provided below about useful system variables: self, @rowcode, @optioncode, and @current. self For validation conditions, a very useful system generate variable isself. This variable denotes the value of the question being validated. Using self instead of the question’s variable name in a question’s validation conditions is advised because you will not have to change the variable name in the validation condition if the variable name for the question is changed.

August 16, 2016

Syntax Guide: Operators

Designer has built-in operators that can be used in enabling conditions or validations. This article explains the following operators that you can use in your instrument: Arithmetic operators Relational operators Logical operators Other useful operators  Arithmetic Operators  The following table shows the arithmetic operators supported by Survey Solutions. Arithmetic expressions are evaluated from left to right. For the example, assume A = 20 and B = 10

August 15, 2016

Dealing with exceptions

An exception is a situation where the computer can’t proceed with a normal flow of commands. A common example is a division by zero. The result of this operation is not defined. In statistics a concept of a missing value is introduced, and we normally don’t bother about the process. We know the result of X divided by zero ;will be a missing. In C# division by zero will cause the program to abort with an exception.

August 10, 2016

Data types

Survey Solutions uses C# language for enabling and validation conditions. C# is a contemporary general purpose object-oriented programming language, widely documented. When writing expressions in C# language, and especially when using standard C# and custom Survey Solutions functions it is important to keep in mind the definitions of the various Survey Solutions objects. Below the types of Survey Solutions objects are explained in terms of standard C# classes and types.

August 9, 2016