Liz's Stata Guide

Commands: Files

This page covers commands for working with files -- the commands that allow Stata to interact with your operating system to read in data and to output data.

use
Loads a Stata dataset (a file with the .dta extension) into memory.
use "filepath\mydataset"

clear
Clears Stata's memory -- of the dataset, as well as any labels, scalars, matrices or anything else you might have had defined.
clear

save
Saves the contents of memory to a Stata dataset.
save "filepath\mynewdataset"

insheet
Reads data into memory from a plain text file (delimited by commas or tabs).
insheet using "filepath\datafromexcel.txt"

input
Allows you to enter data directly into Stata, either from a .do file or interactively.
input varx vary; 2 3; 5 6;

outsheet
Writes data to a tab (or comma) seperated file.
outsheet varx vary using "filepath\results"

file management
Various techniques to avoid typing out the full filepath everytime you want to use one of these commands.

contact: djiboliz@gmail.com
last modified: 17 Sept 2008