Stata commands for sensor data

As part of the launch of SurveyCTO version 2.50, we introduced support for collecting sensor data from Android devices being used to collect data. Briefly, this functionality allows SurveyCTO users to capture data from device sensors that measure light, movement and sound. For ease and convenience, sensor data is available in the form of ready statistics, for immediately usable indicators. For those interested, SurveyCTO’s sensor data can also produce a stream of readings for the duration of a form’s completion. For specific details, please see the relevant product documentation.

For Stata users who are interested in the stream output of device sensors, we have good news! Through collaboration with a longtime SurveyCTO user, Kristoffer Bjärkefur, Stata commands specially design to make the most of sensor streams are now available to use.

Both these commands in some way replicate what the sensor_statistics field does, but with the advantage that you do not have to specify the statistics you want before you collect the data, you can do so after data collection when you have all the data.

Note: In order to use these commands, you must collect data with sensor_stream fields in your form design, to generate raw streams of sensor readings alongside your form submissions.

Getting started

To install, type "ssc install scto" in the Stata command window. Type "help scto" into the Stata command window to read associated documentation.

The code is available on

The "scto" package includes two commands:


The sctostreamsum command reads sensor stream CSV files and calculates statistics for each submission and saves them all in a Stata .dta file that can be merged with the main survey data using SurveyCTO’s unique submission IDs. This can provide you with the output of the sensor_statistics field - and more, even after the data collection. For example, you can change the cut-off for the statistics you define. Even better, you can do this once you more clearly understand how the devices you use collect sound, light and movement, in the context of your data collection.


The sctostreamcsv command reads sensor stream CSV files and calculates statistics for each time period used when collecting the sensor stream. This command can be used to see which part of a questionnaire was done in a particular context in terms of perceivable light, movement and sound. So instead of just getting a percentage of the full interview for a particular sensor reading, you can tell, for example, if the beginning of the survey was dark and/or quiet. The command writes a new CSV file with the calculated statistics on time period level which include file names, for each submission’s sensor stream file used as an input.

sctostreamsum and sctostreamcsv have many options - and we’re curious to learn what has been useful to you! For example, you might query stream data for what was happening in relation to a particular field. You can then merge the output statistics into your main dataset.

We’d love to hear from you about your sensor data experiences! Leave comments here, and consider sharing your experiences in our user forum.

Do you have thoughts on this support article? We'd love to hear them! Feel free to fill out this feedback form.


Article is closed for comments.