Toggle navigation
Home
▼ Details
Products and pricing
Chart gallery
User stories
Text analytics
CDC NAMCS Library
Blog
Tutorials
Contact
Sign in
Post Editor
← All help posts
View post
Save
<img src="/uploads/upload/image/5200/direct/1571404480058-1571404480056.png" alt="Simple diagram showing the transformation '[NA]→0' in a light gray box, illustrating the concept of recoding missing values to zero." class="fr-fic fr-dib"> [Missing values](/view-access/na-blank-missing-values "Go to NA article") can represent a quantity that is actually known. This can occur with skip logic, where \[NA\] values might mean zero or a quantity from a prior answer. For example, a survey asked "How many many energy packs did you purchased last week?" This question is asked only of respondents who indicated they made at least some purchase. <img src="/uploads/upload/image/5200/direct/1572375170833-1572375170833.png" alt="Protobi chart showing Q18 'How many energy packs did you purchase last week?' with a horizontal bar chart. The data shows [NA] at 10.0%, followed by responses 1 through 7 with varying percentages. The mean is 2.57 with N=100." style="width: 525px;" class="fr-fic fr-dib"> <img src="/uploads/upload/image/5200/direct/1571405441850-1571405441849.png" alt="Context menu showing options including 'Select to copy as text', 'Copy as image', 'Round by...', 'Statistics...', 'Color...', 'Format...', and 'Recode...' highlighted at the bottom with a blue tooltip explaining it translates verbatim responses or changes specific values for analysis." style="width: 240px;" class="fr-fic fr-dib"> Here the mean number of purchases was 2.57, and 10% of respondents have \[NA\] indicating the question was not answered. However, in this case, we know that \[NA\] values aren't really missing and exactly how many packs they purchased: zero. ## Recode missing values One approach is to [Recode](/videos/recode-text-for-analysis-video) missing values. Press the edit icon for the element and select "Recode..." from the context menu: This will bring up the recode dialog: <img src="/uploads/upload/image/5200/direct/1571408559907-1571408559907.png" alt="Recode dialog interface with two columns: 'Codes' on the left showing a '(New code)' button, and 'Uncoded values' on the right listing values: (uncoded) with count 6, followed by 2, [NA] (highlighted), 3, 4, 1, and 5." style="width: 860px;" class="fr-fic fr-dib"> Drag the value \[NA\] to the "(New code)" button and enter the value 0 at the prompt. This will recode missing values to zero: <img src="/uploads/upload/image/5200/direct/1571405513582-1571405513581.png" alt="Recode dialog showing the result after recoding [NA] to 0. The 'Codes' section on the left displays '(New code)' button and a new code '0' mapped from 1 instance of [NA]. The 'Uncoded values' section shows '(uncoded)' with count 0." style="width: 480px;" class="fr-fic fr-dib"> Voilá, the distribution now shows 10% of respondents with zero purchases, and the mean is now 2.31, a bit lower: <img src="/uploads/upload/image/5200/direct/1572375408310-1572375408310.png" alt="Protobi chart showing Q18 'How many energy packs did you purchase last week?' after zero-filling. The bar chart now shows 0 at 10.0% (highlighted in gray), followed by values 1 through 7. The mean has decreased to 2.31 with N=100." style="width: 528px;" class="fr-fic fr-dib"> **Note**: When elements are skipped due to skip-pattern, it would be appropriate to add an [element specific filter](/edit-access/element-filters) to the element or group. ## Advanced alternative: Zero-fill via data processing If the group to be recoded is complex, you may want to try this method. Create JavaScript codes as a [data process](/110842-under-construction-internal/oldarticle) instead. For example, a group could be summing to 100, but respondents are not required to enter a 0 in every box: ### Zero-fill data process code the code below zero-fills when some of the children are populated, and \[NA\] fill for elements that are partially populated with 0, but no non-zero values are included. ``` var rows = data.main // List the group and its children in an array called zero_fill var zero_fill = [ {"key": "Q2", "children": ["Q2_1","Q2_2","Q2_3","Q2_4","Q2_5","Q2_6"]}, {"key": "Q3", "children": ["Q3_1","Q3_2","Q3_3","Q3_4","Q3_5","Q3_6"]} ] // Run through zero fill code for each respondent rows.forEach(function(row){ zero_fill.forEach(function(entry){ key=entry.key; children = entry.children; children.forEach(function(child){ row[key] = (row[key] || 0) + (+row[child] || 0); }) if (row[key] == 0) { row[key]=""; children.forEach(function(child){ row[child] = ""; // NA fill those respondents that has 0 total }) } else // if (row[key] == 100) // Could add logic Zero fill respondents only that seen part of the question and has total = 100 { children.forEach(function(child){ row[child] = (row[child] || 0); }) } // else console.log(row.respid, key) }) }) ```
Publishing
Date
Status
Published
Draft
Slug
edit
Content
Thumbnail
Categories
Manage
New to Protobi?
Charts
Making Changes
Intermediate topics for editors
Frequently Asked Questions
SERMO Topics
Tutorial Pages
Internal Docs
Data Processing
Videos
Obsolete
GSG Admin
SERMO Admin
GSG Topics
How to...
Basics for viewers
Basics for editors
For project admins
Advanced topics
Assessments
Articles (in-progress)
New and updated articles
Process data in Protobi
superseded
Text open-end questions
Troubleshooting
Tracking studies
Organizing the view
API References
Tools
AI Database
Checking AI...
Convert to MD
Danger zone
Delete