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/1691061778074-image.png" alt="Table Properties dialog for "process" showing JSON configuration with "ADVANCED USERS ONLY! properties in JSON" warning. The code displays a "stacked_elements" array containing elements like "c6", "c7", "c8", "c8_98_other", "c9", "c9_98_other", "c10_1" through "c10_98", "c10_98_other", and "c15", followed by a "date_intervals" array with objects defining time intervals with "key", "start", "end", and "unit" properties." width="417px"> Table properties lets you store variable definitions separately from the process logic. A variable is just a “named storage” for data, and many people like to define all the variables they plan to use at the top of a data process so that they are easy to find and modify. With table properties, your variable definitions are on a separate page which keeps your process logic cleaner and makes reading and editing code easier. This is especially useful when variable definitions are expansive which can take up a lot of rows of your data process and make it hard to locate specific code. ## Values accepted in table properties Tables properties is defined as an object. Objects in Javascript are a collection of properties, and each property is a a key (name) and value pair. Properties can have the following values: - String - Numeric - Boolean - An array - An object ## Practical use We recommend variables with long definitions like a list of questions or complex functions be stored in table properties. Variables you can store in table properties: - Questions that you want to operate on in the data process - Data columns you want to merge with your survey data from an auxiliary data file - Data columns you want to stack (i.e. a patient chart module) - Data columns you want to delete - Date objects with information for time interval calculations - Objects with group name (key) and children definitions - Functions (reusable blocks of code that do a specific task) ## How to get to table properties Each data process has its own table properties. You can get to table properties from the process setup page by pressing the “Properties” button. <img src="/uploads/upload/image/5200/direct/1691064299613-image.png" alt="Protobi process configuration panel for "process" showing form fields: Name ("process"), Type ("process"), Process type ("Simple"), Resources ("URLs, one per line"), Updated ("Wed Aug 02, 2023 02:50 pm"), Filename ("process.csv"), Description (empty), Visibility ("Project"), Status ("Active"), and an "Edit properties" button. View section has "Data online", "Direct", and "Properties" buttons (Properties highlighted in red). Admin section shows "Edit/Run", "Delete", and "Primary" (orange) buttons. Download section shows "Original", "CSV", "SPSS", "Excel" buttons." width="344px"> You can also get to table properties from the code view page by pressing “Properties…” next to the “Run…” button. <img src="/uploads/upload/image/5200/direct/1691064330287-image.png" alt="Protobi "Data process 'process'" interface showing "Project settings" sidebar and main code editor. The page displays text explaining this is a "Simple" data process that returns an array of row objects and runs synchronously. The JavaScript code shows: var rows = data["main"], console.log statements for "table", "stacked_elements", "zero_fill", and "date_intervals", followed by variable declarations: let stacked_elements = param["stacked_elements"], let zero_fill = param["zero_fill"], let date_intervals = param["date_intervals"]. The Properties button is highlighted in red."> ## Table properties page In the table properties example below, we include a few common examples of pre-defined variables that can make the data process long and hard to manage. We recommend you store these definitions in table properties. **Store keys and keep arrays for left\_join data merges** The “keys" and “keep” properties are arrays and we reference these variables in code that [joins additional data to the survey data file.](/process-data/tbd-csv-left-join) **Store keys and groups to reference in zero\_fill code** The zero\_fill property is an array of objects with keys and children. The keys and children are used in the zero-fill code to [replace missing values with zeros](/intermediate-editor/zero-filling) in question batteries that sum to 100. Expand to see example code for table properties. ## Table properties ```plain { "keys": [ "respid" ], "keep": [ "q6_coded", "q15_coded", "q23_coded", "q24_coded_1", "q25_coded_2", "q26_coded_3", "q27_coded_4", "q28_coded_5", "q29_coded_6" ], "zero_fill": [ { "key": "q20", "children": [ "q20_1", "q20_2", "q20_3", "q20_4", "q20_5", "q20_6", "q20_7", "q20_8", "q20_98" ] }, { "key": "q25", "children": [ "q25_1", "q25_2", "q25_3", "q25_4", "q25_5", "q25_6", "q25_7", "q25_8", "q25_98" ] }, { "key": "q30", "children": [ "q30_1", "q30_2", "q30_3", "q30_4", "q30_5", "q30_6", "q30_7", "q30_8", "q30_98" ] } ] } ``` ## Data process page Expand the data process code below to see how the table properties defined above are used. ## Data process ```plain /** * @by tiffany@protobi.com * @created 2023-07-25 * @see (enter URL of Freshdesk support ticket or other reference) * Define a Javascript program that returns an array of objects representing row data when complete. * All data tables (blue icons) are pre-loaded and available as attributes of a variable called `data`. * This example below reads data from table `main`, and iterates over each row * Tutorial at https://help.protobi.com/advancedusers/process-data-in-protobi */ var rows = data["main"] // read rows of data table titled "main" var OE = data["OE"] //auxiliary data file //TL, 2023-07-25 //Declare a new variable param and set the value to the table properties let param = table.properties //Declare the attributes you want to bring in from the table properties let keys = param["keys"] let keep = param["keep"] let zero_fill = param["zero_fill"] //TL, 2023-07-25 //Join in coded open-end data //Keys are merge keys. //Keeps are all the fields to add to the main data file or replace existing data. rows = Protobi.left_join( rows, //left table (project's existing data) OE, //right table (data to be joined into project) keys, //join keys keep //the variables from the right table to join ); rows.forEach(function(row) { //TL, 2023/07/25, zero-fill code //Zero and [NA] fill question batteries 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 { children.forEach(function(child) { row[child] = (row[child] || 0); }) } }) }) return rows; ```
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