New In

Saving, using, and describing a set of frames

You work with multiple datasets in memory, also known as frames. When those datasets are related—perhaps they are used in the same project or linked to each other—you can now bundle them in a frameset. Save all of the datasets in one file. Use them all together later.

Highlights

  • Local projection estimates of impulse–response functions

    • Simple IRFs

    • Orthogonalized IRFs

    • Dynamic multipliers

  • Save and compare models with the irf suite

  • Tabulate or graph impulse responses with irf table and irf graph

Overview

In Stata 16, data frames were introduced to allow working with multiple datasets in memory. With frame commands, you can create frames and load datasets in them, copy frames, change the current (working) frame, use the frame prefix, etc. For more information on the capabilities of frames, see [D] frames intro or this overview.

Stata 18 adds a natural evolution of the frames concept: users can now save a set of frames (known as a frameset) using frames save. The frameset can later be restored in memory with frames use. When saving framesets on disk, they are automatically compressed. You can also automatically save frames that are linked. For more information on linked frames and variable aliases in linked frames (another feature introduced in Stata 18), see this overview.

frames describe allows you to take stock of frames and the variables they hold, both in memory and on disk. The frameset commands also store numerous r-class results to keep track of results of actions taken, e.g., the subset of frames saved or loaded, whether or not data in each frame has changed in memory, the size of compressed files, etc.

A new data format is introduced for framesets: .dtas, the plural of .dta. Stata allows reading and writing .dtas files with ease. Nonetheless, all the required information is provided in case a programmer wants to have other software create or read a .dtas file. Type help dtas in Stata for more details.

The syntax and options of frameset commands quite naturally follow those of dataset commands like save, use, and describe. For example, dataset and frameset commands similarly handle things like labels, empty datasets, the level of detail in describing datasets, etc.

Let’s see it work

Suppose you are working on a project about the population census and its relation to housing for different states in the United States. You are using two Stata datasets: census and hsng. You can load the two datasets in two frames as follows:

. clear all
. frame create census
. frame change census
. webuse census
. frame create housing
. frame change housing
. webuse hsng
. pwf

The current frame is housing, as revealed by pwf (print working frame).

We now use frlink to link frame housing to frame census, matching observations one to one based on variable state.

. frlink 1:1 state, frame(census)

Although not required here, we can use fralias add to create variable aliases that reference variables in a linked frame. An alias is like a copy of a variable from the linked frame, but it uses very little memory and you cannot modify its observations. For example, we can create alias d, which references variable divorce (number of divorces) in linked frame census with

. fralias add d = divorce, from(census)

The following command can be used to save frame housing and all other frames linked to it (in this case, census) in a .dtas file, say, myframeset.dtas:

. frames save myframeset, frames(housing) linked

The .dtas extension is assumed in frames save, just like in frames use and frames describe.

You can remind yourself what is in myframeset.dtas with

. frames describe using myframeset

You can clear all frames in memory and load all frames in myframeset.dtas with

. frames use myframeset, frames(_all) clear