Lookup table, string and dynamic questions

Hello!

I am running a survey experiment where respondents pick some cards at random. Each card has a scenario printed on it. I’d like the enumerator to select the chosen card on the CAPI (coded as a categorical question), and for the system to display text instructions with the features of the selected scenario embedded in.
To do so, I’ve created a lookup table where each row is a scenario, and each column is a feature.
When a card is selected, the features are retrieved from the lookup table and stored in some variables, called later by a text box.
I’m attaching a screenshot of what the output looks like
Capture

Question: Some of the features displayed in the textbox should be strings (e.g. the type of job or location). Is there a way/syntax for me to attach/display a label to these numerical values (e.g. from a reusable category) and print them as strings?
I was thinking something like categoryJob[lookupTable[card_num].job], where categoryJob is a reusable category, but not sure this is possible/correct.

Thanks!

I am afraid I fail to see the logic of what you are doing here.
The flash cards should contain all the necessary information and a clearly visible number.
Example

Or, specifically for your case:


  JOB : "Mayor"
  Hours: "25"
  Location: "New York, NY"
  Income: "$3000"
  Card number: "21"

Once the respondent has selected a card, the interviewer should inspect the chosen card and enter the card number. For example, 21.

Since you are preparing the cards, all the information that is printed on them is available for you in the office. Have it arranged in a form of a nice Excel file or a similar storage. You just need to know what is selected at random in the field.

Perhaps the key is in the

Which means that you are not going to be asking the question “Would you rather prefer a job in the location on the card to your current job?”, but instead “Would you rather prefer a job in New York, NY to your current job?

Good idea. But incomplete. Why have the cards at all then? If the substitution of the features is done by the program, not the respondent, then what is the point to have the cards at all? to print any features on them? Survey Solutions should be capable of generating random scenarios based on a random number that it draws on it’s own.

PS: if you are motivated by the case discussed in

then the key feature of those flashcards is a photograph, which can’t be generated from some random elements. If it was text, that would eliminate the need for the flashcards.

Hello Sergiy,

thanks for the thoughtful answer. While I understand your doubts, there are specific reasons why we do the survey experiment in this way - I was more interested in “how do I store and retrieve a numbered list of strings?” rather than “should I do it?”.
But here are the details:
The survey experiment involves rating a sequence of randomly generated scenarios (a pair of two randomly selected cards is a scenario). All of the scenarios will be randomised beforehand and preloaded. However, we want the first scenario to be randomised on the field, in front of the respondent, as to make it very salient that the two cards are matched at random (we’ll ask the respondents to pick cards themselves to increase the salience). The reason for this is that we don’t want any inference to be drawn from the way pairs are formed (there’ll be a spouse on each card).
In this first iteration of the experiment, drawn at random “live”, we want to use cards with pictures because not all respondents are comfortable reading, we want to limit the cognitive effort required by the task, and we want to breakup the Q&A back-and-forth flow of the longer survey this experiment is a part of.
Now, as for the reason why I want this information to be displayed on the CAPI, it is twofold: I want to be certain enumerators stick to a pre-specified script without having to rely on enumerator training alone (I’d like them to read, not interpret), and this provides us an additional straightforward way to check that the card selected on the CAPI matches the one shown to the respondents.
I could pre-print the script on the cards, but again, this might make some respondents feel uncomfortable, and there is a part of the script that relies on the sum on variable displayed on each cards, as well as other randomised parameters.
I perfectly understand this might not be the way anyone would run a similar exercise, but this how we decided to it, at least for the pilot. We did take into consideration several issues, and I thank you for your inputs, but the short answer is: we’ll pilot the experiment as described :slight_smile:

Going back to my original question, is there a way to store a numbered list of strings, retrieve a (str) value from this list based on a (int) value of a variable, and display it in a text box?
Alternatively, if I upload a reusable category, is there a syntax to retrieve one of the values?
Apologies, I am not conversant in C++, otherwise I am sure the solution would have been straightforward.

Thank you very much.

Hello Andrea,

I don’t think you can access reusable categories unless they appear as part of a Select question, and then only the actual selected categories.
What I did in similar situations was to define variables like:

String variable: job
expression:

lookupTable[card_num].job == 1 ? “Agriculture” :
lookupTable[card_num].job == 2 ? “Manufacturing” :
lookupTable[card_num].job == 3 ? “Construction” :
. . .

In other words hardwiring the categories in the variable.

A variation would be:

String variable: job
expression:

new string[]{
“Agriculture”,
“Manufacturing”,
“Construction”
}[(int) lookupTable[card_num].job-1]

The cast to (int) in the last line is necessary because the lookup table returns a double.
Probably this also needs to be done in the first variation.

1 Like

Hello @andrea_s , thank you for explaining. It looks like you do have a conscious decision with good justification for your strategy. Indeed making the respondent to do the randomization will increase the belief to the selection being really random, and having the pictures and calculated results are good justifications for your strategy.

Lookup tables can only store and retrieve numeric content. So they are not the solution.

My first advice would be what is illustrated in the “Public example User questions and common patterns” “Days of the week (Spanish)” example:


which is also what Klaus’ second suggestion is.

But be aware that this solution is not going to be language-sensitive (if this is your case).

As an alternative, perhaps you can consider 25 static texts, and a condition which turns on only one of them depending on the entered number of the selected card.

For example:

“Imagine that you are being offered a job as a Mayor in New York, NY, and your salary will be $3,000, but at this time you can only sell your house for $%housePrice%. I will ask you a series of questions about how you may wish to talk with your spouse/partner about the important decision to relocate…”
Q1
Q2
Q3

This works best if you can read the whole scenario, then start asking questions (Q1,Q2,Q3…) without further referring to the details.

The advantage is that it will be responsive to the language, the disadvantage is if you later find that you need to change a word in your scenario description, you will need to do it N times (though we still think of N as a small and manageable number, since this is the number of printed cards).

Besides the arrays already mentioned, C# also has lists for similar purposes:

PS:

I understand. We all come to this forum for various objectives. My objective is to understand “how the product is being used?” and “for which surveys?” and “what features are essential for the users?” and “how is it done in other systems?”, etc. Unfortunately we live in a world where mentioning the name of the survey is a taboo, and any other details are beyond even mentioning.

Hope this helps.

Best, Sergiy