Professional > Interview scripting > Writing interview scripts > Working with sample records > Updating sample records with interview data
 
Updating sample records with interview data
If you have a panel of respondents that you survey regularly, you can build up a profile of each respondent and save the key points as part of the respondent’s sample record. You can check periodically that the profile is still valid and update it if necessary.
Note If the data is completely new, you will need to add a new field to the sample file. You may be able to do this yourself; if not, ask your UNICOM Intelligence administrator to do it for you.
To write interview data into the sample record, type:
IOM.SampleRecord.Item["FieldName"] = Value
in the routing section of the script, where:
FieldName is the name of the sample field you want to write to. It’s a good idea to use similar names for the question and its related field in the sample record. as this helps to ensure that you copy the correct data into each sample field. If your script has sample quotas, you may want to use identical names for questions and sample fields. For more information, see Sample quotas when you have No Access to the sample database.
Value is the information you want to place in the sample field. This can be a fixed value such as a number or a text, or the name of a question or variable that stores the information. Sample tables do not support categorical values as such. If you want to save categorical data in your sample records you will have to convert it into a numeric or text form first. For more information, see Converting data to the required format.
For example:
IOM.SampleRecord.Item["SampleAge"] = Age.Response.Value
to write the answer to the Age question into the SampleAge sample field. If SampleAge already contains data it will be overwritten.
Here’s a longer example that shows how you can load existing sample data into the interview, check that it is still correct, and then update any out-of-date sample fields with new data. The metadata section defines the questions related to the sample fields:
Mstat "Please confirm your marital status" categorical [1..1]
{
Single, Married, Divorced, Widowed,
Partner "Living with partner"
};
Empstat "Please confirm your employment status" categorical [1..1]
{
Employed "Working for an employer",
SelfEmployed "Self-employed",
Homemaker, Retired,
Student "In full-time education",
Unemployed "Unemployed but able to work",
Unable "Unable to work (e.g., disability)"
};
Children "How many children do you have?" long [0..9];
The routing script that loads the sample data into these questions and writes the new answers back into the sample records is as follows:
Empstat.Response.Value = IOM.SampleRecord.Item["SampleEmpstat"]
Children.Response.Value = IOM.SampleRecord.Item["SampleChildren"]
Empstat.Ask() Children.Ask()
IOM.SampleRecord.Item["SampleEmpstat"] =
    Empstat.Response.Value.Format("a")
IOM.SampleRecord.Item["SampleChildren"] = Children.Response.Value
The sample data is loaded into the questions, so the questions are displayed with these answers already selected or filled in. If the current answer is correct, respondents can click Next to move to the next question; if not, they can select or enter a new answer. The answers to the questions are written back into the sample fields. If the fields already contain values, this data is overwritten by the current answers to the questions, even if the new value is the same as the old one. In this way you can be sure that all the information in the sample records is up to date.
See also
Working with sample records