Inserting Variables in SurveyWriter

Anywhere you enter text in SurveyWriter, you can insert respondent answers from previous survey questions using Variable Inserts. Typically, variables are inserted into the text of a question using the IQ button on the HTML Editor button bar. These variables are dynamically populated with the actual respondent answers when the respondent views that question.

Many types of variable inserts are available. Below is a summary of the available options.

Variable Insert Syntax    
Example Explanation
GENERAL
QID = Question ID
   
|QID|  |Q15| Standard variable format: question information replaces variable at that spot at which you placed it in the text.
\QID\ \Q15\ Replaces standard variable format if you are working on a branch question and already have inserted the branch symbol, |, in the text.
|QID-Other1|
|QID-Other2|
|QID-Other3|..., etc.
|Q5-Other1|

|Q5-Other2|
Pulls in question information from the first Other text field in the specified question. 

Pulls in question information from the second Other text field in the specified question if more than one is available.
|QID-R3-Other1| |Q15-R3-Other1| Pulls in Other text field. Other text field originates in a row question.
|QID-Other1-Branch*BRANCHCODE| |QID-Other1-Branch*BRANCHCODE| Pipe in Other text field in the loop that you are on. Other text field originates in a branching question.
|QID*Code| |F8*1| Used to pull in value associated with a specific code for a question.
BRANCHING     
|*BranchLabel| |*BranchLabel| In a branch loop, returns the label of the loop that you are on. Use in place of  branching symbol, |, in Header, Grid Row Title, Column Label Heading, and Row Label Header. | was designed for Question text only.
|*BranchNumber| |*BranchNumber| In a branch loop, returns the number of the loop that you are on.
|*Branchcode| |*Branchcode| In a branch loop, returns the code of the loop that you are on. 
\QID-Branch*BRANCHCODE\ \Q15-Branch*BRANCHCODE\ Used in conjunction with the branching symbol | to pull in the branch code associated with a branching item.
|QID@BranchNumber| IQ1-Branch1| In a branch loop, returns the number of the branch in the loop from the associated question.
FETCH
The fetch command is used to populate the survey from an outside data source, such as an Excel spreadsheet or a delimited ASCII file.
|FETCH(A1)| |FETCH(A1)| Use to pull data from a fetch file from Column A1.
|FETCH(A1,QID)| |FETCH(A1,Frandom)| A1 indicates that we are pulling data from column A1 in the Fetch file. Because we've included a question ID next to the column number, SurveyWriter substitutes the result from the question Frandom in place of a regular password to indicate the row from which to take data in A1. If the question Frandom returns a 3, data is pulled from the Fetch file from A1, Row 3.
\FETCH(A1,pw=|)\ \FETCH(A1,pw=|)\ A1 indicates that we are pulling data from column A1 in the Fetch file. PW=| indicates that we want SurveyWriter to substitute the result from the branch parent question in place of a regular password to indicate the row from which to take data in A1. If the parent question returns a 3 for the first branch, data is pulled from the Fetch file from A1, Row 3.
|FETCH(A1,BULK,QID)| |FETCH(A1,BULK,Frandom)| This format is used to pull in multiple Response Codes simultaneously from a fetch file for use in the answer options of a single question.

A1 indicates that we are pulling data from column A1 in the Fetch file. BULK indicates that this a bulk fetch and we are pulling in more than one option at a time. SurveyWriter substitutes the result from the question Frandom in place of a regular password to indicate the row from which to take data in A1. If the question Frandom returns a 3, data is pulled from the Fetch file from A1, Row 3.

The syntax for the fetch file to store multiple variables in a single cell is:

1::Male~2::Female~3::No Answer

1:: = Answer Code
Male
= Answer Label
~
= Separator

MISCELLANEOUS
QTEXT(QID) |QTEXT(Q17)| Insert Question text from specified question.
HTEXT(QID) |HTEXT(Q17)| Insert Header text from specified question.
[[|QID|+|QID|]] [[|Q5|+|Q7|]] Insert Calculations into follow question using the results from previous questions. The following operators are available:
  • + (addition) 
  •  - (subtraction)
  •  * (multiplication) 
  •  / (division) 
  • ^ (exponentiation)
  • Sqr (square root)
  • Atn (arctangent value) 
  • Cos (cosine) 
  • Exp (raise the exponential power for logarithm) 
  • log (return the exponential power for logarithm) 
  • Sin (sine)
  • Tan (tangent)
[[ROUND|QID|*|QID|]] [[ROUND|Q7|*|Q7|]] Insert Calculations with rounding.
|Resp_ID| |Resp_ID| Inserts respondent's ID number. 
|password| |password| Inserts respondent's password.