Long
The long type defines an integer question, which is a question that requires a whole number response. The response data is stored using the Long data type, which is a 32-bit signed integer in the range -2,147,483,648 to 2,147,483,647.
Syntax
For clarity, each item is shown on a separate line, and optional items are indented. See also
Syntax conventions.
field_name [ "field_label" ]
[ [ <properties> ] ]
[ <styles and templates> ]
long [ [ range_expression ] ]
[ precision (\integer) ]
[ <categories> ]
[ <codes> ]
[ expression ("expression_text") ]
[ ( initialanswer | defaultanswer ) (integer) ]
[ <axis> ]
[ <usage-type> ]
[ <helperfields> ]
[ nocasedata ]
[ unversioned ]
Parameters
For
<axis>,
<usage-type>,
<helperfields>,
nocasedata, and
unversioned, see
Common parameters.
range_expression
To specify
|
Syntax
|
any whole number
|
Field long;
Example
Quantity long;
Any whole number between -2,147,483,648 and 2,147,483,647 is valid.
|
a range of values
|
Field long [ n1 .. n2 ];
Example
Visits long [1..99];
All whole numbers between 1 and 99 inclusive are valid.
|
a minimum to undefined max.
|
Field long [ n1 .. ];
Example
People long [1..];
All whole numbers greater than 0 are valid.
|
from undefined min. to max.
|
Field long [ .. n1 ];
Example
Cars long [..10];
All whole numbers less than 11 are valid.
|
single values
(not supported in Data Model 2.8)
|
Field long [ n1 , n2 , n3 , n4 ...];
Example: Size long [100, 200, 500];
Values 100, 200, and 500 are valid.
|
several different ranges
|
Field long [ n1 .. n2 , n3 .. n4 , n5 .. n6 ...];
Example:
Rate1 long [24..56, 100..1000];
All whole numbers between 24 and 56 inclusive and between 100 and 1000 inclusive are valid.
|
exclusive values
|
Field long [ ^ n1 .. n2 ];
Example:
Grade long [1..10, ^5..7];
All whole numbers between 1 and 10 inclusive, except the whole numbers between 5 and 7 inclusive. (In other words, 1, 2, 3, 4, 8, 9, 10.)
|
stepped values
|
Field long [ n1 .. n2 step n3 ];
Example:
DressSize "Dress size" long [6..30 step 2];
All whole numbers between 6 and 30 inclusive in steps of 2. (In other words, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30.)
|
precision
An optional precision value can be used to validate an answer against the defined precision value. When the answer exceeds the defined precision value, an error message indicating that the answer contains too many digits is generated.
An optional precision value can be used to validate an answer against the defined precision value. When the answer exceeds the defined precision value, an error message indicating that the answer contains too many digits is generated.
<categories>
You can use the optional categories list to specify that the question will be presented as a single-response categorical question. If a category is selected, the value of the response will be the factor value assigned to that category by the factor keyword. Therefore, all categories should be assigned a factor value. In the following example, the value of Income will be 5000, 15000, or 25000, depending on which of the three categories is selected:
Income "What is your annual income?" long
{ low "0 to 10,000" factor(5000),
medium "10,000 to 20,000" factor(15000),
high "20,000 to 30,000" factor(25000)
};
For further information about defining a category list, see
Categorical.
<codes>
The optional codes list is used to define special responses for the question. A code list is defined in the same way as a category list and is typically used to include Don't Know, No Answer, or Refused to Answer responses, which are identified by the DK, NA and REF keywords respectively. For example, the following numeric question called Rate has Don't Know and Refused to Answer responses. Special responses are automatically marked as exclusive, meaning that they cannot be combined with any other answers. Only whole numbers 1 to 100, Don't know or Refused to Answer are acceptable responses to this question:
Rate long [1 .. 100] codes (
{ DontKnow "Don't know" DK,
Refused "Refused to answer" REF
} );
When using the DK, REF or NA keywords, you can use a hyphen (-) as the category name to specify that the category name should be the same as the keyword.
expression
You use the optional expression keyword to create a variable using a formula defined in expression_text. Generally you use this feature to create a derived variable that is based on one or more other variables. For example, the following creates a variable that is the sum of the Adults and Children numeric variables, which record the number of adults and children in the household respectively.
TotalPeople "Total number of people in the household" long
expression("Adults + Children");
expression_text must be an expression that is supported by the UNICOM Intelligence Data Model and can optionally include functions from the
UNICOM Intelligence Function Library. Double quotation marks (") must be escaped using a second double quotation mark (for example,
""yyyy""). Make sure that you check your syntax and spelling carefully, because the expression is stored without being validated. For more information, see
Expression evaluation.
initialanswer and defaultanswer
You can optionally specify either an initial answer or a default answer to the question. An initial answer can be seen by the respondent, whereas a default answer can not be seen. If either type of answer is defined, the respondent does not need to answer the question. For example:
Rating "Rate the product from 1 (poor) to 10 (excellent)" long [1 .. 10]
initialanswer(5);
If a default answer is not accepted when you run the interview script, in other words, the message “Missing Answer(s)” is displayed, see
mrScriptMetadata FAQs.
Remarks
For more information about writing Long questions in interview scripts, see
Questions with integer responses.
Example
The following defines a numeric question called Visits with the question text How many times have you visited before today?, for which any positive whole number less than 100 or Don't Know are valid responses:
Visits "How many times have you visited before today?" long [1 .. 99]
codes (
{
- "Not sure" DK
} );
See