Stata Frames
Frames are in-memory datasets.
Description
Conventionally, Stata only has an active, in-memory dataset. The -frame- command operates as a wrapper for interacting with multiple, in-memory datasets.
To list all frames, try frame dir. The active dataset is automatically assigned the label default. This subcommand also lists sizes (i.e., rows x columns) and dataset labels.
To re-label a frames, try:
frame rename default oldframe
To switch between frames, try:
frame change newframe
Usage
An existing dataset is copied into a new frame like:
frame copy default copied
A new, empty frame is created like:
frame create myframe
Rows and columns can be copied from the active dataset into a frame like:
frame put foo bar baz if foo==1, into(myframe)
Clearing Frames
To drop one or more frames, try:
frame drop frame1 frame2 frame3
Note that the active dataset cannot be dropped this way.
To completely reset the state of frames, try frame reset.
Frame Scope
A frame scope can be used to run one statement in another frame. Try:
frame newframe: summ foo
The frame state returns to the current frame at the end of this statement.
