Stata 15 help for snapshot

[D] snapshot -- Save and restore data snapshots


Save snapshot

snapshot save [, label("label")]

Change snapshot label

snapshot label snapshot# "label"

Restore snapshot

snapshot restore snapshot#

List snapshots

snapshot list [_all | numlist]

Erase snapshots

snapshot erase _all | numlist


Data > Data Editor > Data Editor (Edit)


snapshot saves to disk and restores from disk copies of the data in memory. snapshot's main purpose is to allow the Data Editor to save and restore data snapshots during an interactive editing session. A more popular alternative for programmers is preserve.

Snapshots are referred to by a snapshot#. If no snapshots currently exist, the next snapshot saved will receive a snapshot# of 1. If snapshots do exist, the next snapshot saved will receive a snapshot# one greater than the highest existing snapshot#.

snapshot save creates a temporary file containing a copy of the data currently in memory and attaches an optional label (up to 80 characters) to the saved snapshot. Up to 1,000 snapshots may be saved.

snapshot label changes the label on the specified snapshot.

snapshot restore replaces the data in memory with the data from the specified snapshot.

snapshot list lists specified snapshots.

snapshot erase erases specified snapshots.


label("label") is for use with snapshot save and allows you to label a snapshot when saving it.


Setup . webuse auto

Describe the dataset . describe

Save a snapshot of the dataset . snapshot save, label("before changes")

Change the dataset . generate gpm = 1/mpg . label variable gpm "gallons per mile"

Save a snapshot of the changed dataset . snapshot save, label("after changes")

Make an unwanted change to the dataset . drop gpm

List available snapshots . snapshot list

Restore a snapshot . snapshot restore 2

Describe the dataset . describe

Relabel a snapshot and erase an unneeded snapshot . snapshot label 2 "good changes" . snapshot erase 1

List available snapshots . snapshot list

Stored results

snapshot save stores the following in r():

Scalars r(snapshot) sequence number of snapshot saved

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index