And here is how you would -simulate- the thing. With 3 observations and
2 slopes plus constant, this model is not well identified, to put it
mildly, so the standard errors are lacking and the last lines cannot
work... John, how do you intend to remedy the situation?

Thanks for the reply and the code! You are so helpful with everyone
and always seem to be able to find an elegant solution! As an aside,
what is a nice resource to learn how to program nicely in Stata?

I made a mistake in the 3), which you noticed.

So, this was 2)--(I am only putting one space after each entry so that
the formatting doesn't get too messed up):

I want to do something that is quite straightforward, but don't yet
have the programming skills to do this, so I would appreciate some
help. Basically, I want to select randomly within clusters, then
collapse, then estimate a regression model that I would like to
simulate. I would like to define it as an e-class program so that I
can easily incorporate a simulation in there.

I have the following data structure (I have added a line in-between
clusters to facilitate viewing):

Where y is the dependent variable, and x and z are covariates (note,
I have more covariates, so I would like to use something general that
works even with more covariates), "i" is the panel identifier and "n"
is number of observations in each cluster. Note that each cluster
does not have the same number of observations

I would like to do the following:

1) by cluster (i.e., within in each cluster), randomly split the
observations into two groups, with an equal amount of observations
(if number of observations are even); if the number of observations
are odd, then one of the group will have 1 more observation than the
other. Thus, I would now have this: