Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Design characteristics integratedin the database - CBC

I create a CBC on Lighthouse studio, and I would like to download the data with the design integrated. In other words, I would like to have the design characteristics for each of the choices integrated with the database.
Is it possible?
If not, how bad is it if I set 1 design version (it is 300 by default)?

Thank you in advance for your help,
related to an answer for: Data in long format
asked Nov 17, 2020 by Maria Lagomarsino (245 points)

2 Answers

0 votes
Best answer
Another option to add to Bryan's would be to record the design data while the survey is running.  This would be beneficial if you want to do something with the design data while the survey is going on (e.g., skips).  Fortunately, this shouldn't be too tricky.

I would start by creating a free format question on the same page as the first CBC task.  It should be given hidden variables with names like "_concept1level1," "_concept2level3," etc., reflecting the number of concepts and attributes of your CBC.  Now place this script in the free format HTML:

[% Begin Unverified Perl
# Parameters
my $concepts = 4;
my $levels = 4;

# Run
my $output = '';
for (my $i = 1; $i <= $concepts; $i++) {
    for (my $j = 1; $j <= $levels; $j++) {
        my $variable = QUESTIONNAME() . '_concept' . $i . 'level' . $j;
        $output .= '<input name="' . $variable . '" id="' . $variable . '" type="hidden" value=""/>';
return $output;
End Unverified %]

and this script in the CBC:

    [% Begin Unverified Perl
    # Parameters
    my $concepts = 4;
    my $levels = 4;
    # Run
    my @conceptDesigns = ();
    for (my $i = 1; $i <= $concepts; $i++) {
        my @levels = ();
        for (my $j = 1; $j <= $levels; $j++) {
            push(@levels, CBCDESIGNLEVELVALUE(QUESTIONNAME(), $i , $j));
        push(@conceptDesigns, '[' . join(',', @levels) . ']');
    return 'var design = [' . join(',', @conceptDesigns) . '];';
    End Unverified %]

    var ff = $('#[% QuestionName() %]_div').nextAll('.freeformat').get(0).id.replace(/_div$/, '');
    for (var i = 1; i <= design.length; i++) {
        for (var j = 1; j <= design[i - 1].length; j++) {
            $('#' + ff + '_concept' + i + 'level' + j).val(design[i - 1][j - 1]);

The code should automatically do everything for you, but be sure to look for "# Parameters" in both scripts and update the lines beneath them with your number of concepts and number of attributes.
answered Nov 17, 2020 by Zachary Platinum Sawtooth Software, Inc. (164,025 points)
selected Nov 17, 2020 by Maria Lagomarsino
Thank you very much Zachary.  I did what you suggested, but I have a few follow-up questions.
In my CBC design, I have 6 attributes (two levels each) and 2 concepts for each task. Respondents answered  12 tasks in total.
- I updated the # Parameters
                                my $concepts = 2;
                                my $levels = 6;
  and I created 12 hidden variables in a free format question (D = design; C= concept; A= attribute):
 1.    D1_C1A1
2.    D1_C1A2
3.    D1_C1A3
4.    D1_C1A4
5.    D1_C1A5
6.    D1_C1A6
7.    D1_C2A1
8.    D1_C2A2
9.    D1_C2A3
10.    D1_C2A4
11.    D1_C2A5
12.    D1_C2A6

However, nothing is recorded when I download the data. I changed the data type as either text or whole number, but nothing changes.
Do you know what may be wrong?
- Additionally, I need a free format question for each of the 12 tasks, right?

Thank you in advance for your help!
Oh yeah, you will need to copy-and-paste the free format question so that one exists beneath each CBC task.

Are those the exact free format variable names?  The code expects the names to be "_conceptXlevelY."  If different names are to be used, line 10 of the first script and line 23 of the second would need to be adjusted accordingly.
Right! That works!

In my survey I have 4 CBCs and respondents are randomly assigned to one of them. To record their design characteristics, I did the same for the 4 CBCs (I changed the name of the free format question variables).
When I tried to upload it (hosting service), I received the following error (Log error):

ERROR [AutoUploader] 18 Nov 2020 17:15:43.075 : The server returned the following error message: Database error. Cannot alter table adding new columns. System Error: DBD::mysql::db do failed: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs at /users/user_82419/htdocs/cgi-bin/admin.pl line 17.

Do you know how can I fix it?
Should I change something in the CBCs script?
That looks like a somewhat separate issue, but lowering the "Max Fields per Database Table" in your study settings might help.
0 votes
It is possible, with some work on your part.  Here are the steps:

1. Edit any of your CBC tasks, click the Design tab.  Click Export Design to export the design for the 300 versions (or 10 versions, for that matter, which would be sufficient) to a .CSV file.  
2.  You will need to do some data processing using your own tools to put each design's information onto a single row, instead of the design listed across multiple rows in the .CSV.
3.  After you have collected data and downloaded the data into your data table on your local hard drive, export each respondent's CaseID and CBC Design ID variables into a .CSV file.
4.  You can use your own tools (Excel's VLookup can do this) to merge the information about each respondent's received CBC design into that modified design file you created.  Now, you have a .CSV file that has each respondent ID, and all the combinations of product concepts the respondent saw in all CBC tasks on the same row.
5.  In the Data Management,  Get Data area, you can click the option to merge data into the data table using "External, on-survey data (.CSV)".  You'll be merging the info from that file you created in the previous step.

And, it is often a bad idea to field just one version of the experimental design.  If you do so, make sure that 1 version of the design can estimate the effects of interest to you with high precision (main effects only, or some two-way interactions between certain attributes that you KNOW ahead of time you want to estimate interaction effects for).  Then, if you are comfortable that a 1-version plan can get you high precision for the effects of interest, make sure to randomize the order of presentation of CBC tasks to respondents.
answered Nov 17, 2020 by Bryan Orme Platinum Sawtooth Software, Inc. (181,965 points)
Thanks :)