0 votes
in SoSci Survey (English) by s048152 (200 points)
retagged by s048152

This urn we created places people randomly into 1 of 3 conditions (control, exp1, exp2) based on age group (young, middle, older), and then we send them 30 more surveys based on their condition over 60 days. The value of the condition is stored in IV02_01. See the code below:

// Für jede Altergruppe eine Urne: Wert wird aber in gleicher Variable gespeichert (ökonomischer).
 
if (value('SD19') == 1) {
urnDraw('condag1', 'IV02'); }
 
if (value('SD19') == 2) {
urnDraw('condag2', 'IV02'); }
 
if (value('SD19') == 3) {
urnDraw('condag3', 'IV02'); }
 
//Bei NEIN (== 2) wird die Person auf die Seite "no IC" weitergeleitet und nochmals gefragt, ob sie sich sicher ist.
 
$cond = value('IV02_01');

This variable appears in this first survey (where the Urn is located) when I download the dataset. However, in the follow-up surveys, it does not, and thus I cannot see which condition the participants are in. We draw from the urn and send the next survey correctly, but the variable does not appear in the dataset during analysis making it difficult to see which group they are in. See the code below:

//get infos from baseline: condition and diet
 
$keyc = 'CO-'.caseSerial();
$keyd = 'DI-'.caseSerial();
 
$cond = dbGet($keyc);
$diet = dbGet($keyd);

How do I make this variable appear in the dataset in the other surveys as well?

Thank you!

1 Answer

0 votes
by SoSci Survey (327k points)

How do I make this variable appear in the dataset in the other surveys as well?

Do you also use dbSet to store the codes? This code will store the values from IV02_01 and IV03_01 to the database for contents.

$key = 'C-'.caseSerial();
dbSet($key, [
  value('IV02_01'), 
  value('IV03_01')
]);

It that works, you can simply copy the code from there in the follow-up surveys:

$key = 'C-'.caseSerial();
$data = dbGet($key);
if ($data) {
  put('IV02_01', $dataC[0]);
  put('IV03_01', $dataC[1]);
}
by s048152 (200 points)
Thank you for the response. So, we create the variables in the previous code I gave, and we store the values using the following code:

> $cond = value('IV02_01');
> $keyc = 'CO-'.caseSerial();
> dbSet($keyc, $cond);

I believe this is then stored in the database where we draw from to send the correct surveys based on conditions.

I tried your code, but I don't see the value of IV02_01 appear in the dataset under collected data. Does it matter if we have already collected data, or does it need to be a new/fresh survey? We have essentially stopped collecting data already. I am analyzing the data and want to see the condition appear in the dataset of each subsequent survey.
by SoSci Survey (327k points)
> I believe this is then stored in the database

Did you check if it is there? You can select the database for contents in the menu in the special features.

> I tried your code, but I don't see the value of IV02_01 appear in the dataset under collected data

Add a warning to show if the entry is not found in the database.

if ($data) {
  put('IV02_01', $dataC[0]);
  put('IV03_01', $dataC[1]);
} else {
  html('<p>No entry found for '.caseSerial().'</p>');
  buttonHide();
}

In the example above, I store both values in one entry. So, if you have already stored values in separate entries, make sure to use your code - but so not only retrieve the value to a PHP variable

$cond = dbGet($keyc);

(note that this will return an array!) but also store the value to a dataset variable:

put('IV02_01', $cond[0]);

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...