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

Re: st: Collapse and then generate the id of multilevel


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: Collapse and then generate the id of multilevel
Date   Fri, 19 Dec 2003 09:28:45 +0100

Saengla Chaimongkol wrote:
> Dear Statalist,
>
> I am working at the three level model(school, student and item).Thus, I
> need to collapse the data at level two because there are many students at
> the same school get the same response to each item.
>
> However, when I collapse, I need to generate the student id for each
> school. For example, I have 20 students in each school. Thus, in school1,
> the student id shoul be 1-20 or less than 20. Then school 2, the student
> id should be start at 1-20 or less than 20, etc.
>
> When I use the command
> gen cons=1
> collapse (count) wt2=cons,by(schid,item)
> gen stuid=_n
>
> Then the output gives me the stuid from 1- 789( the last observations)
>
> Could any one give me a suggestion please?

. by schid, sort: gen stuid = _n

-- 
[email protected]
+49 (030) 25491-361


*
*   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