Stata 11 help for expandcl

help expandcl dialog: expandcl -------------------------------------------------------------------------------

Title

[D] expandcl -- Duplicate clustered observations

Syntax

expandcl [=]exp [if] [in] , cluster(varlist) generate(newvar)

Menu

Data > Create or change data > Other variable-transformation commands > Duplicate clustered observations

Description

expandcl duplicates clusters of observations and generates a new variable that identifies the clusters uniquely.

expandcl replaces each cluster in the dataset with n copies of the cluster, where n is equal to the required expression rounded to the nearest integer. The expression is required to be constant within cluster. If the expression is less than 1 or equal to missing, it is interpreted as if it were 1, and the cluster is retained but not duplicated.

Options

cluster(varlist) is required and specifies the variables that identify the clusters before expanding the data.

generate(newvar) is required and stores unique identifiers for the duplicated clusters in newvar. newvar will identify the clusters by using consecutive integers starting from 1.

Example

Setup . webuse expclxmpl

List the data . list, sep(0)

Replace each cluster with n copies of the cluster . expandcl n, generate(newcl) cluster(cl)

Sort the observations based on values of newcl, cl, and x . sort newcl cl x

List the resulting data . list, sepby(newcl)

Also see

Manual: [D] expandcl

Help: [R] bsample, [D] expand


© Copyright 1996–2009 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index