Thanks as always to Kit Baum, a new version of the expgen package is now available for download from SSC. In Stata, use the ssc command to do this, or adoupdate if you already have an old version of expgen.
The expgen package is described as below on my website. The new version adds a second module lexpgen, which expands the current dataset using a numlist of values specified in the option clevels(numlist), and stores the values in that numlist in a new variable specified by the clevels(newvarname) option. This is useful if we want to create a dataset containing a factorial design matrix.
Best wishes
Roger
-------------------------------------------------------------------------
package expgen from http://www.rogernewsonresources.org.uk/stata10
-------------------------------------------------------------------------
TITLE
expgen: Duplicate observations and add generated variables
DESCRIPTION/AUTHOR(S)
expgen is an extended version of expand. It replaces each
observation in the current dataset with nc copies of the
observation, sorted in the original order, where nc is equal to the
integer part int(ncexp) of the required expression ncexp. expgen
may also add new variables. These are newvarname1 (containing the
value of the expression ncexp), newvarname2 (containing the
sequential order of the original observation in the old dataset),
and newvarname3 (containing the sequential order of each copy in
the set of copies generated from its original observation). If
missing and/or zero is specified, then observations in the old
dataset with missing and/or non-positive values for int(ncexp) are
each replaced by one observation in the new dataset. lexpgen is an
alternative version of expgen. It replaces each observation in the
current dataset with one copy of the observation for each of a
user-specified input list of numbers, sorted primarily in the
original order, and secondarily by the numbers in the list. It may
add the new variables added by expgen, and/or another new variable
newvarname4, containing the number in the input list of numbers
corresponding to the copy.
Author: Roger Newson
Distribution-Date: 22march2024
Stata-Version: 10
INSTALLATION FILES (click here to instal
> l)
expgen.ado
expgen.sthlp
lexpgen.ado
lexpgen.sthlp
-------------------------------------------------------------------------
(click here to return to the previous screen)
The expgen package is described as below on my website. The new version adds a second module lexpgen, which expands the current dataset using a numlist of values specified in the option clevels(numlist), and stores the values in that numlist in a new variable specified by the clevels(newvarname) option. This is useful if we want to create a dataset containing a factorial design matrix.
Best wishes
Roger
-------------------------------------------------------------------------
package expgen from http://www.rogernewsonresources.org.uk/stata10
-------------------------------------------------------------------------
TITLE
expgen: Duplicate observations and add generated variables
DESCRIPTION/AUTHOR(S)
expgen is an extended version of expand. It replaces each
observation in the current dataset with nc copies of the
observation, sorted in the original order, where nc is equal to the
integer part int(ncexp) of the required expression ncexp. expgen
may also add new variables. These are newvarname1 (containing the
value of the expression ncexp), newvarname2 (containing the
sequential order of the original observation in the old dataset),
and newvarname3 (containing the sequential order of each copy in
the set of copies generated from its original observation). If
missing and/or zero is specified, then observations in the old
dataset with missing and/or non-positive values for int(ncexp) are
each replaced by one observation in the new dataset. lexpgen is an
alternative version of expgen. It replaces each observation in the
current dataset with one copy of the observation for each of a
user-specified input list of numbers, sorted primarily in the
original order, and secondarily by the numbers in the list. It may
add the new variables added by expgen, and/or another new variable
newvarname4, containing the number in the input list of numbers
corresponding to the copy.
Author: Roger Newson
Distribution-Date: 22march2024
Stata-Version: 10
INSTALLATION FILES (click here to instal
> l)
expgen.ado
expgen.sthlp
lexpgen.ado
lexpgen.sthlp
-------------------------------------------------------------------------
(click here to return to the previous screen)