Fills are used to customize
question text based on respondents' specific characteristics. This is done by embedding CSPro logic expressions into the text and surrounding them with pairs of tilde characters (~~).
Fills may contain any valid CSPro logic expression that evaluates to a string or numeric value. Logic expressions may include dictionary items, variables, occurrence labels, user-defined functions, as well as any built-in CSPro functions and operators.
Enter some question text that needs to be customized. For words or phrases that need to be filled, enter a dictionary item or variable with ~~ characters before and after. For example:
Can I speak with ~~FIRST_NAME~~ now?
When the entry system comes to this text, it will insert the person's FIRST_NAME value into the question text:
Can I speak with Marjorie now?
Can I speak with Allyson now?
When used with numeric values, the fill uses the value code. For example, ~~SEX~~ might be 1 or 2. If you want to use the value label, you can use the
getvaluelabel function:
How old was ~~FIRST_NAME~~ when they completed ~~getvaluelabel(HIGHEST_GRADE_COMPLETED)~~?
You can customize the question text by inserting an item or group's
occurrence labels into the text. For example:
How much did you spend on ~~getocclabel()~~ in the last month?
You can insert the return value of a
user-defined function into the question text. The function can return either numeric or string values. For example:
Thinking now about ~~FIRST_NAME~~, what is ~~SexPronoun()~~ age?
In logic, a user-defined function must be declared, as in:
You can use HTML tags in order to dynamically format fills using logic. If you use HTML tags, you must surround the fill with three tildes (~~~) instead of two. This tells CSPro not to escape the tags when substituting the fill value. If you use the standard two tildes ~~, the literal HTML will substituted instead of the formatted value.
For example the question text:
You have entered the following household members:
with the following logic:
householdMembers = "<ul><li>Bouba</li><li>Frank</li><li>Chen</li></ul>";
will result in:
You have entered the following household members:
Or more realistically: