*! version 1.1.0 01jul2009
help sequencex

Syntax

sequencex
[var1] [var2] ... [var30], diaryid(string) diaryst(n)

Description

sequencex -- transforms an episode file in long format —where each row represents an episode of activity— into another episode file defined by different variables.
A new episode will be defined any time there is a change in any of the variables specified in the syntax.
The new episode file will be a simplified version of the original one and will most likely contain fewer episodes than the original.
It may be a good idea to run epichecks before using this program, because if there were any errors in 'start' and/or 'end,' the program may not produce the desired results.
If however, the starting file is a calendar file, use the program sequence instead.

Arguments

var1 to var30: variable/s used to define the episode of activity. These variables are usually the activity and the other diary fields such as location, copresence, etc... Up to 30 variables can be specified to define the episodes of activity. The variables need to be numeric, strings are not allowed.

diaryid(string): the names of the variable or variables that when considered jointly uniquely identify the diary.

diaryst(n): diary start time, a number is expected. eg. 4 if the diary starts at 4 am or 0 if the diary starts at midnight. A 24-hour clock is used.

Variables that need to exist

In addition to the variables specified in the argument, the following variable START needs to be there for the program to work:

start: start time of the episode of activity expressed as minute of the day. It can take values from 0 to 1439.

Outcomes

epnum: variable indicating the episode number for each data row.

start: variable showing the start time of the episode of activity expressed as minute of the day. It can take values from 0 to 1439.

end: variable showing the end time of the episode of activity expressed as minute of the day. It can take values from 1 to 1440.

time: shows the duration of the episode of activity (=end-start).

clockst: start time of the activity expressed in clock format.

Examples

The following lines of code load the dataset "example_diary.dta" -an episode file where the episodes of activity are defined by the following variables:
primary activity, secondary activity, copresence, location, and enjoyment among others- and creates new episode files defined by fewer variables.

Example 1: episodes defined by primary activity only

This could be useful if you are only interested in changes in the primary activity.

. net get timeuse

. use diary, clear

. sequencex primary, diaryid(personid diaryid) diaryst(4)

Example 2: episodes defined by the copresence fields

If you are not interested in what people are doing but on where they are, this transformation could make sense.

. net get timeuse

. use diary, clear

. sequencex ww_alone ww_child ww_partner ww_other, diaryid(personid diaryid) diaryst(4)

Example 3: episodes defined by the enjoyment field

This may be useful if you are interested in exploring how often people change their mood throughout the day.

. net get timeuse

. use diary, clear

. sequencex enjoyment, diaryid(personid diaryid) diaryst(4)

Author

Juana Lamote de Grignon Pérez, Centre for Time Use Research (UCL), juana.lamote@gmail.com

Thanks for citing this software as follows:

Lamote de Grignon, J. (2024). sequencex: Stata module to create episode files from other episode files. Available from: https://ideas.repec.org/c/boc/bocode/s459346.html.

Acknowledgments

I am grateful to Elena Mylona and Margarita Vega Rapún for their feedback during the development of the program.