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

st: Collapse and then generate the id of multilevel

From   Saengla Chaimongkol <>
Subject   st: Collapse and then generate the id of multilevel
Date   Fri, 19 Dec 2003 01:59:27 -0500 (EST)

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?

Thank you very much in advance for any suggestion,
Sincerely Yours,


*   For searches and help try:

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