Hi, So I have one question which I’d like to modify the question text for depending on previous answer. (whether enumerator should record from observation or ask to respondent). I know I could make this with two separate questions easily but I was thinking something along the lines of the below could be a more elegant solution.
- Create a string variable
- Populate the string variable with 1 of 2 possible strings depending on previous answer.
- Pipe the string variable into my question text using %VARNAME%.
Is this possible? and if so can someone help me out with the C# language to make a basic If / Else statement to populate the string variable?
suppose you have a categorical single choice question Q1:
Q1: What is your dwelling type?
- private house
And a subsequent question Q2:
Q2: Does your dwelling have a ________ ?
And you wish to plug in “balcony” for an apartment, and “garden” for a private house.
The way to do this is to include a string variable:
asset= (Q1==1) ? “balcony” : “garden”
You can subsequently include %asset% text substitution into the text of the question Q2.
The question mark operator of C# is an equivalent of Stata’s cond() function and MS Office Excel’s IF() function.
It is formally described in the following Microsoft’s reference:
Best, Sergiy Radyakin
Yes, unicode characters can be stored in a string variable.
Data types utilized in Survey Solutions are described in the Data Types article:
and in the content linked from there.
Thanks Sergiy, yes that answers my question but then I thought about how this would be handled with different languages. Is it possible to store unicode characters in the string variable?
As a follow up to this question: suppose I want to insert “balcony” for an apartment, and “garden” for a private house (as in the example your provided above), is there a way to create a string variable that will display “balcony” and “garden” in the various language that the survey is being conducted? Is there a way to condition the output based on the language of the interview?
For simplicity, suppose I want to display “balcony” if apartment and interview in English; “balcón” if apartment and interview in Spanish. Likewise, “garden” if private house and interivew in English; "jardin"in private household and interview in Spanish.
There is no way to create a VARIABLE that would have different content depending on the language selected. This is done intentionally.
For this case I’d probably create a multiselect question in Y/N mode and have the categories filtered based on the previous question, e.g.
Does your dwelling have …?
(1) Y/N balcony
(2) Y/N garden
(3) Y/N swimming pool
(4) Y/N security guard
With filter @optioncode==Q1
This will leave only one option with a possibility to have it selected.