• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
      • Introduction to Data Entry
      • Data Entry Application
      • Data Entry Editing
      • CAPI Data Entry
        • Introduction to CAPI
        • CAPI Features
        • Capture Types
        • Multimedia
        • CAPI Strategies
        • How to ...
          • Create a New CAPI Application
          • Define Languages
          • Organize Forms
          • Enter Question Text
          • Create Fills In Questions
          • Edit Styles
          • Change Formatting
          • Add Images
          • Insert Link In Question Text
          • HTML Question Text
          • Question Text Macros
          • Resource Folders
          • Use Multiple Languages
          • Create Conditional Questions
          • Structure Movement
          • Create Helps for Fields
          • Show Values for Selection
          • Handle Multiple Answers
          • Choose Topic Sections
          • Create General Helps
          • Test Application
      • Network Data Entry
      • Android Data Entry
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Create Fills In Questions

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.
Fills with Dictionary Items or Variables
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)~~?
Fills with Occurrence Labels
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?
Fills with User-Defined Functions
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:
function string SexPronoun()

   
recode SEX -> SexPronoun;
           
1   -> "his";
               -> 
"her";
   
endrecode;

end;
HTML in Fills
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:
~~~householdMembers~~~
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:

  • Bouba
  • Frank
  • Chen
Or more realistically:
householdMembers = "<ul>";

do numeric ctr = 1 while ctr <= totocc(PERSON_REC)
    householdMembers = householdMembers + 
maketext("<li>%s</li>", encode(strip(NAME(ctr))));
enddo;

householdMembers = householdMembers + 
"</ul>"
See also: HTML Question Text