Version: 1.0.0
Date: January 24, 2026
To install, user can use the net install command to download from the project’s Github page:
net install labstore, from("https://aarondwolf.github.io/labstore")
labstore action [varlist] [, options]
| Option | Description |
|---|---|
| action | One of preserve, restore, or print; required |
| varlist | List of variables; optional for preserve and restore (defaults to all variables) |
labels(name \| none) |
Associative array name for labels. Default: varlabs. Use labels(none) to skip labels. |
notes(name \| none) |
Associative array name for notes. Default: varnotes. Use notes(none) to skip notes. |
replace |
Overwrite existing labels or notes arrays without error |
labstore preserves variable labels and notes in Mata associative arrays before data transformations (such as collapse, reshape, or merge), and restores them afterward. This is useful when operations that modify variables or reduce observations would otherwise lose label and note information.
The program has three main actions:
preserve: Store variable labels and/or notes from the dataset into Mata associative arrays. These arrays remain in memory for later restoration.
restore: Apply stored labels and/or notes from Mata associative arrays back to variables in the current dataset. Variables not found in the arrays are skipped silently.
print: Display the contents of stored labels and/or notes arrays in a formatted table.
By default, both labels and notes are preserved/restored using the array names varlabs and varnotes. You can customize these names, or disable labels or notes with labels(none) or notes(none).
For the preserve action, if no varlist is specified, all variables in the dataset are used. For restore, you should specify the variables you want to restore to (typically all variables after a data transformation). For print, varlist is not used.
Labels are stored as Stata variable labels (accessible via label variable). Notes are stored as Stata variable characteristics and retrieved using notes syntax.
If you attempt to preserve with an array name that already exists in memory, labstore will refuse to overwrite unless you specify the replace option.
. sysuse auto
. labstore preserve
. collapse (mean) price mpg weight, by(foreign)
. labstore restore _all
. labstore preserve price mpg rep78, notes(none)
. labstore restore _all, notes(my_notes_backup) labels(none)
. labstore print
. labstore preserve price-gear_ratio, labels(orig_labels) notes(orig_notes)
. labstore restore _all, labels(orig_labels) notes(orig_notes)
. labstore preserve _all, replace
Aaron Wolf, Northwestern University
aaron.wolf@u.northwestern.edu
help label: Stata’s built-in label systemhelp notes: Stata’s built-in notes system