Harmonize values of variables within by-groups
harmby varlist [ , by(by_varlist) ]
Description
harmby ("harmonize within by-groups") checks that each variable in the varlist has no more than one value, other than the standard missing value, in each of the by-groups specified by by(), or in the whole data set, if by() is not specified. A standard missing value is . for a numeric variable, or the empty string "" for a string variable. If this condition is true, then harmby replaces all standard missing values in the by-group (or data set) by the one value that is not standard missing, if such a value exists, and takes no action if all values in a by-group (or data set) are standard missing. harmby is useful if there are variables whose values should be unique within each by-group (or within the data set), and new observations with standard missing values for these variables have been added to some or all of the by-groups by merge, or by ingap, which is downloadable from SSC.
Options
by(by_varlist) specifies a list of variables defining the by-groups. The data set does not have to be sorted by those variables, and remains sorted in its original order after harmby has run.
Examples
. harmby N N_clust depvar, by(idnum idstr)
Author
Roger Newson, King's College, London, UK. Email: roger.newson@kcl.ac.uk
Also see
Manual: [R] merge, [R] by On-line: help for merge, by help for ingap if installed