Modify survey data

Updated at January 30th, 2020

When analyzing your project you might find yourself wanting to make changes to the survey data. 

For instance you might want to:


This article shows two ways you can modify the survey data for a Protobi project. Let's take a look at an example where we want to enter missing survey data.

For this dataset we know that respondents from wave 2 of study 123 have the specialty "PCP." However, fielding was inconsistent and the data column "speciality" came back blank for some respondents in the survey.

To enter the missing data we can either: 

  • Download and make changes directly to the date file
  • Use code to make a data processing rule

Modify the data file directly

One way to modify data is to directly makes changes to the data file and re-upload into Protobi. See the steps below.

We don't recommend his method as best practice because you or a teammate might need to repeat these edits later with new data.

1. Download your data file in CSV format from the data tab of project settings. 

2. Open the file in Excel and make the necessary revisions.

3. The last step is to re-upload the file into your project. In the data tab create a new data table, and drop in the revised CSV file. Make sure you set the new data table as primary.

Note: You could upload the revised file into an existing data table. However, if you're going to use this method we recommend creating a new data table. This way the old data file won't be overwritten and is available for future reference.      

Use code to process the data

Another way to revise data is to use Protobi's data processing capabilities. We can make a rule using code in pre-calculate that is run each time the project is opened, which is useful for smaller code or when the study is still in field. The pre-calculate page is found in project settings. We can also write code that runs once on request and stores the result for rapid access (aka Data process). This is useful when the code is complex or you want to lock the result down. The code seen below will work in both places.

We prefer the method of revising data with back-end code when possible. It can potentially save time and minimize human error. The benefit of writing rules or changes as code is that they can be reapplied when new data arrives. You wouldn't want to revise and upload the file manually each time a new data file came in.

And in terms of documentation, having the rules written in code in Protobi allows you to keep better track of what was done to the project. It's also convenient in case you ever need to revise or reverse the process. 

The code below follows a simple logic statement. If data column studyId equals "123" and wave equals "2," then speciality equals "PCP." 

rows.forEach(function(row){ //Iterate through each data row
  
if (row.studyId == '123' && row.wave == '2') { row.specialty == 'PCP';} //change specialty to PC for study with studyId ='123' in wave 2.

}); return rows;

See related

Update project data

Process data in Protobi


Was this article helpful?