EconPapers    
Economics at your fingertips  
 

KEYBY: Stata module to key the dataset by a variable list

Roger Newson

Statistical Software Components from Boston College Department of Economics

Abstract: keyby sorts the dataset currently in memory by the variables in a varlist, checking that the variables in the varlist uniquely identify the observations. This makes the variables in the varlist a primary key for the dataset in memory. If the user does not specify otherwise, then keyby also reorders the variables in the varlist to the start of the variable order in the dataset, and checks that all values of these variables are nonmissing. keybygen sorts the dataset currently in memory by the variables in a varlist, preserving the existing order of observations within each by-group, and then generates a new variable, containing the sequential order of each observation within its by-group, to form a primary key with the existing variables in the varlist. keyby and keybygen can be useful if the user combines multiple datasets using merge, which may cause a dataset in memory to become unsorted.

Language: Stata
Requires: Stata version 10.0
Keywords: data manipulation; sort; key (search for similar items in EconPapers)
Date: 2007-08-31, Revised 2014-07-30
Note: This module should be installed from within Stata by typing "ssc install keyby". The module is made available under terms of the GPL v3 (https://www.gnu.org/licenses/gpl-3.0.txt). Windows users should not attempt to download these files with a web browser.
References: Add references at CitEc
Citations:

Downloads: (external link)
http://fmwww.bc.edu/repec/bocode/k/keyby.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/k/keyby.sthlp help file (text/plain)
http://fmwww.bc.edu/repec/bocode/k/keybygen.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/k/keybygen.sthlp help file (text/plain)

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:boc:bocode:s456866

Ordering information: This software item can be ordered from
http://repec.org/docs/ssc.php

Access Statistics for this software item

More software in Statistical Software Components from Boston College Department of Economics Boston College, 140 Commonwealth Avenue, Chestnut Hill MA 02467 USA. Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().

 
Page updated 2025-03-30
Handle: RePEc:boc:bocode:s456866