[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: RE: how to create a HLM dataset
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
Quoting Nick Cox <firstname.lastname@example.org>:
> -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?
> Joseph Coveney replied to Min Zhang
> > I'm not sure how to set up random counts of counties-within-states and
> > districts-within-counties using -egen , seq()-, but perhaps
> > the following
> > might create the data structure that your'e looking for.
> > (I'm not sure whether school districts are always nested
> > within counties.
> > In any event, I believe that you can get the actual rosters
> > of counties and
> > of school districts--Nick's second suggestion--from the U.S.
> > Bureau of the
> > Census. Check the bureau's website in the SAIPE area:
> > "Small Area Income &
> > Poverty Estimates--Model-based Estimates for States, Counties & School
> > Districts.")
> > set obs 50
> > generate byte state_id = _n
> > generate byte county_id = ceil(50 * uniform()) // 50 is arbitrary
> > expand county_id
> > bysort state_id: replace county_id = _n
> > generate byte school_district_id = ceil(5 * uniform()) // 5 ditto
> > expand school_district_id
> > bysort state_id county_id: replace school_district_id = _n
> * 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/
* For searches and help try: