Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: how to create a HLM dataset


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: how to create a HLM dataset
Date   Thu, 15 Sep 2005 22:21:22 +0100

Once again, it is impossible to comment 
on code you do not show us. 

A simple example of the use of -egen, seq()-: 

Let's set up 50 states X 50 counties X 10 districts: 

set obs 25000 

* we want 500 replicates of each state id: 

egen state = seq(), block(500) 

* within each state 10 replicates of each county 

bysort state: egen county = seq(), block(10) 

* within each county, ids 1 up 

bysort state county : egen district = seq() 

Nick 
[email protected] 

mzhang
 
> well. forget about the random counts. I use uniform 
> distribution in my case.
> And what I want to do is to know how to use stata to create a 
> dataset with
> "nested" structure. I tried to use nested loops to do this. 
> however, it failed.
> therefore I want to know how to use egen seq() to set up 
> identifiers to achieve this goal.
 
Nick Cox 

> > -egen, seq()- could be useful for setting
> > up a set of identifiers. It is of no use
> > for generating random counts, however
> > defined. There is a fair chunk in the
> > manual entry on -egen- on -seq()-.
> >
> > I don't know what random counts means in the
> > abstract here without any specification
> > of a distribution. Alternatively, if by
> > random you mean just "arbitrary" or "any
> > old numbers will do", then why not
> > use a real dataset instead?
> >

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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