*! version 1.0.2 22 Apr 2026

Title

clocklabel -- Create a clock-style value label for minute-of-day variables

Syntax

clocklabel #, [name(lblname) | gen(lblname)] [replace]

where # is the diary start hour, given as an integer from 0 to 23.

# diary start hour on a 24-hour clock, from 0 to 23

name(lblname) name of the value label to create

gen(lblname) alias for name()

replace replace an existing value label with the same name

Description

clocklabel creates a reusable value label that translates minute-of-day values into readable clock times.

This is useful for variables such as start, end, start1, end_last, or any other timing variable expressed as minutes from the start of the diary day.

The command does not modify any data values and does not attach labels to variables automatically. It simply creates a value label, which the user may then apply manually using Stata's label values command.

Arguments

# specifies the diary start hour using an integer from 0 to 23.

Examples:

0 = diary begins at midnight

4 = diary begins at 04:00

18 = diary begins at 18:00

Options

name(lblname) specifies the name of the value label to be created.

gen(lblname) is an alias for name().

Use either name() or gen(), but not both.

replace replaces an existing value label with the same name.

If a label with the chosen name already exists and replace is not specified, the command stops with an error.

How minute-of-day values are interpreted

Values are interpreted relative to the diary start time.

For example, with a diary start hour of 4:

0 04:00

60 05:00

120 06:00

600 14:00

With a diary start hour of 0, value 0 corresponds to midnight.

What the command creates

clocklabel creates a value label with the name supplied in name() or gen().

The label maps minute values from 0 to 1440 into readable clock times.

Code 0 is defined to display the same clock time as code 1440, corresponding to the diary start time on the next day.

Examples

Example 1: Create a label called myclock

. clocklabel 4, name(myclock)

This creates a value label called myclock for diaries that begin at 04:00.

Example 2: Use gen() instead of name()

. clocklabel 4, gen(myclock)

This does exactly the same thing as name(myclock).

Example 3: Attach the label to variables

. clocklabel 4, name(myclock)

. label values start myclock

. label values end myclock

Example 4: Replace an existing label

. clocklabel 0, name(clock0) replace

Remarks

1. Label creation only

This command creates the value label but does not attach it to variables.

2. Use either name() or gen()

These options are equivalent. They should not be used together.

3. Integer hour input

Unlike whatmin and whattime, this command expects the diary start time as an integer hour such as 4, not as a clock string such as 04:00.

4. Reusable across variables

Once created, the same label can be applied to as many timing variables as needed.

5. Useful after data construction

This command is often used after generating timing variables with clock2min, epigen, or timeallocx.

Stored results

clocklabel does not store results in r() or e(). Results are returned through the created value label.

Author

Juana Lamote de Grignon-Pérez

Centre for Time Use Research (CTUR)

Also see

clock2min for converting clock strings into minute-of-day variables.

whatmin and whattime for quick conversions between clock times and minute-of-day values.