*! version 3.0.0 30 Apr 2026

Title

tslotcheck -- Check time-slot completeness and consistency in calendar-format diary files

Syntax

tslotcheck, did(varlist) [quiet]

did(varlist) variable(s) that uniquely identify each diary; required

quiet suppress the success message when no problems are detected

Description

tslotcheck checks whether a calendar-format diary file contains a complete and internally consistent sequence of time slots within each diary.

The command is intended for files in which each row represents one fixed time interval, such as a 10-minute, 15-minute, 30-minute, or 60-minute slot. It is especially useful before running epigen, which converts calendar files into episode files and assumes that tslot correctly represents the order of time slots within each diary.

tslotcheck checks three types of problems: duplicate time slots within diary, time-slot values outside the expected range, and diaries with an unexpected number of rows. It then creates a diary-level flag indicating whether each diary has any detected issue.

Required variables

tslot must exist in the data and must be numeric. It should indicate the order of time slots within each diary.

For example, in a diary with 144 ten-minute slots, tslot should normally run from 1 to 144 within each diary.

Arguments

did(varlist) specifies one or more variables that jointly identify each diary uniquely. Variables may be numeric or string.

Options

quiet suppresses the success message when all diaries appear to have the expected number of slots. If problems are detected, a warning is still displayed.

How the expected number of slots is determined

tslotcheck determines the expected number of slots by first finding the maximum value of tslot within each diary and then taking the median of those diary-level maxima.

This means that the command does not require the user to specify the expected number of slots directly. In a standard 10-minute diary, the inferred number will usually be 144; in a 30-minute diary, it will usually be 48; and in a 60-minute diary, it will usually be 24.

Checks performed

The command checks for the following problems:

Problem code

1 duplicate tslot values within diary

2 out-of-range tslot values, i.e. below 1 or above the expected maximum

3 diary has an unexpected number of rows/slots

The command records the first applicable problem found for each observation in problem_case. The diary-level variable problem_diary is then set to 1 for diaries with at least one detected issue and 0 otherwise.

What the command creates

tslotcheck creates or replaces the following variables:

Output

problem_case observation-level problem code; missing when no issue is detected for that row

problem_diary diary-level flag: 0 = OK diary, 1 = diary has issues

The command also creates an internal grouped diary identifier, __udid. In normal use this variable can be ignored; users may drop it after checking the output if they do not need it.

Output in the Results window

If no problems are detected and quiet is not specified, the command displays a message such as:

All diaries have the expected number of time slots (144).

If problems are detected, the command displays a warning and lists the number and percentage of diaries with and without issues.

Dataset after running the command

tslotcheck does not collapse, reshape, or otherwise change the structure of the data. The original rows remain in place. The command only adds diagnostic variables and replaces any previous variables named problem_case or problem_diary.

Because the command is diagnostic, it does not fix duplicated, missing, or out-of-range time slots. If problems are detected, users should inspect and correct them before running epigen.

Examples

Example 1: Check a standard calendar file

This checks whether each diary identified by uid and day has the expected sequence of time slots.

. tslotcheck, did(uid day)

Example 2: Run quietly before episode creation

This suppresses the success message if no problems are detected. This is useful inside harmonisation scripts or before running epigen.

. tslotcheck, did(uid day) quiet

. epigen activity location, did(uid day) dst(4)

Example 3: Inspect problem diaries

After running tslotcheck, list diaries where at least one issue was found.

. tslotcheck, did(uid day)

. list uid day tslot problem_case if problem_diary == 1, sepby(uid day)

Remarks

1. The command assumes tslot is the intended within-diary ordering variable

If tslot is incorrectly constructed, tslotcheck may identify problems correctly, but it cannot infer the correct order of the diary without additional information.

2. The expected number of slots is inferred from the data

Because the expected number of slots is based on the median of the maximum observed tslot values, the command is robust to a small number of incomplete diaries. However, if many diaries are incomplete in the same way, the inferred expected number may be wrong.

3. The command reports slot-structure problems, not content problems

tslotcheck does not check whether activity, location, or other diary fields are valid. It only checks whether the time-slot structure appears complete and non-duplicated.

4. Run before epigen

It is good practice to run tslotcheck before epigen. If the time-slot sequence is incomplete or duplicated, the episode file created by epigen may have incorrect timing.

Stored results

tslotcheck does not store results in r() or e(). Results are returned through the diagnostic variables created in the dataset.

Author

Juana Lamote de Grignon-Pérez

Centre for Time Use Research (CTUR)

Also see

epigen to create an episode file from a calendar-format diary file.

epicheck to check structural problems in episode-format diary files.