Modify survey data

Updated at September 13th, 2022

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: 

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

Use code to clean the data

Our recommended way to revise data is to clean/process data in Protobi

We can make a rule using code in pre-calculate which runs each time the project is opened. Pre-calculate is useful for smaller code since it is run every time you open the project, or when the study is continuously updated and you don't want to manually run a data process. 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 example seen below will work in both pre-calculate and data process.

Why clean/process data in Protobi?

We prefer the method of revising data with back-end code when possible. 

1. It can potentially save time and minimize human error. 

2. 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.

3. 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. 

Example

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;

Modify the data file directly

Another way to modify data is to directly makes changes to the data file and re-upload into Protobi. 

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

Update project data

Clean/process data

Was this article helpful?