nested data/ easy piece

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

nested data/ easy piece

Dogan, Enis
Dear List,

 

Here is a data set I have in hand:

StudentID   TeacherID     teacher_gender

1                      1                      1

2                      1                      1

3                      1                      1                      

4                      2                      2

5                      2                      2

6                      2                      2

 

I want to know the frequencies of teacher gender. However each teacher
repeats himself as many times as he has students. So if run frq without
any manipulation it will look like I have 3 male and 3 female teachers
whereas I actually I have 1 male and 1 female teacher. How do I
"unweight" the teacher cases.

 

I am considering the following syntax but I thought there has to be an
easier way:

 

Aggregate

/outfile = * mode = addvariables

/break = TeacherID

/Frq = N(TeacherID).

 

 

COMPUTE teach_weig = 1/Frq .

EXECUTE .

 

WEIGHT

  BY teach_weig .

 

Thank you

 

Enis

 

 
Reply | Threaded
Open this post in threaded view
|

Re: nested data/ easy piece

Marta García-Granero
Hi Enis,

DE> StudentID   TeacherID     teacher_gender

DE> 1                      1                      1

DE> 2                      1                      1

DE> 3                      1                      1

DE> 4                      2                      2

DE> 5                      2                      2

DE> 6                      2                      2

DE> I want to know the frequencies of teacher gender. However each teacher
DE> repeats himself as many times as he has students. So if run frq without
DE> any manipulation it will look like I have 3 male and 3 female teachers
DE> whereas I actually I have 1 male and 1 female teacher. How do I
DE> "unweight" the teacher cases.

DATA LIST LIST/StudentID TeacherID teacher_gender (3 F8).
BEGIN DATA
1 1 1
2 1 1
3 1 1
4 2 2
5 2 2
6 2 2
END DATA.

* Select only first ocurrence of each TeacherID *.
COMPUTE select=1.
IF TeacherID=LAG(TeacherID) select=0.
FILTER BY select .

FREQUENCIES VARIABLES=teacher_gender.

Best regards,
Marta