Liz's Stata Guide

Commands: Datasets

This page covers commands that alter the structure of your dataset or allow you to combine two or more datasets.

The pages for most commands in this category need to be written / rewritten

sort
Sorts the observations in a dataset according the value of a variable or variables.
sort varx vary

reshape
Changes how panel data (or panel-like data) is stored.
reshape wide varx vary, i(idvar) j(year)   - or -
reshape long varx vary, i(idvar) j(year)

xpose
Transposes the data so that each observation becomes a variable and each variable becomes an observation.
xpose

compress
Makes Stata see if it can store your dataset more efficiently by changing the types of some variables.
compress

order
Alters the order of the variables in a dataset, as they appear in the Variables window, or in commands like sum and list (when called with no arguements).
order idvar1 idvar2 varx vary varz   - or -
order newvar, after(xvar)

merge
Joins two datasets containing different information (variables) on the same observations.
merge idvar using "files/otherdataset"

append
Joins two datasets containing different observations for the same variables.
append using "files/otherdataset"

contact: djiboliz@gmail.com
last modified: 4 May 2007