Sample Census


This is a pretend census that asks how many people are in your household, asks tailored follow-up for each person, and generates a simple report.

It demonstrates how group-level relevance can make it easier to implement a "loop" of questions. After creating the group for Person 1, I exported the group. Since I used qcode variable names like p1_name instead of the SGQA code, I could use a text editor to quickly edit and re-import the group several times (e.g. it took about 10 seconds to edit and re-import each repeating group, ensuring that all variables had unique variables names and that the group-level logic was correct).

This also shows how you can prevent the Finished message from appearing until the survey is truly finished (e.g. all needed groups are completed).


There are 21 questions in this survey.
Initial Questions
We are going to ask questions about each person in your household.

* What is your name?

* Are your male or female?
* How old are you?

* How many people live with you?

Person 1
* Is this person male or female?
* What is {if (p1_sex == 'M' , 'his' , 'her')} name?

* How old is {p1_name}?

* What is your relationship to {p1_name}?
Choose one of the following answers
So, {name}, {p1_name} is a {p1_age} year old {if(p1_sex=='M','man','woman')}, and is your {if(strlen(p1_rel_other)>=1,p1_rel_other,p1_rel.shown)}.
Person 2
* Is this person male or female?
* What is {if (p2_sex == 'M' , 'his' , 'her')} name?

* How old is {p2_name}?

* What is your relationship to {p2_name}?
Choose one of the following answers
So, {name}, {p2_name} is a {p2_age} year old {if(p2_sex=='M','man','woman')}, and is your {if(strlen(p2_rel_other)>=1,p2_rel_other,p2_rel.shown)}.
Person 3
* Is this person male or female?
* What is {if (p3_sex == 'M' , 'his' , 'her')} name?

* How old is {p3_name}?

* What is your relationship to {p3_name}?
Choose one of the following answers
So, {name}, {p3_name} is a {p3_age} year old {if(p3_sex=='M','man','woman')}, and is your {if(strlen(p3_rel_other)>=1,p3_rel_other,p3_rel.shown)}.
Person 4
* Is this person male or female?
* What is {if (p4_sex == 'M' , 'his' , 'her')} name?

* How old is {p4_name}?

* What is your relationship to {p4_name}?
Choose one of the following answers
So, {name}, {p4_name} is a {p4_age} year old {if(p4_sex=='M','man','woman')}, and is your {if(strlen(p4_rel_other)>=1,p4_rel_other,p4_rel.shown)}.
Summary
Here is a summary of the people living in your household

(1) {name}, a {age} year old {if(gender=='M','man','woman')} with {cohabs} co-habitants
(2) {p1_name}, a {p1_age} year old {if(p1_sex=='M','male','female')} who is your {if(strlen(p1_rel_other)>=1,p1_rel_other,p1_rel.shown)}.
(3) {p2_name}, a {p2_age} year old {if(p2_sex=='M','male','female')} who is your {if(strlen(p2_rel_other)>=1,p2_rel_other,p2_rel.shown)}.
(4) {p3_name}, a {p3_age} year old {if(p3_sex=='M','male','female')} who is your {if(strlen(p3_rel_other)>=1,p3_rel_other,p3_rel.shown)}.
(5) {p4_name}, a {p4_age} year old {if(p4_sex=='M','male','female')} who is your {if(strlen(p4_rel_other)>=1,p4_rel_other,p4_rel.shown)}.
Finished
{name}, thanks for taking our survey. If you have any comments for us, please submit them here.