Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: RE: RE: AW: Creating single values from a nested data file


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: RE: RE: AW: Creating single values from a nested data file
Date   Wed, 16 Dec 2009 16:53:43 +0100

<> 

The missing case with Nick`s proposed solution would then be:


*************
clear*

inp byte(School Student Classize female) 
1	1		.	1
1	2		35	0
1	3		35	1
1	4		35	1
2	1		23	0
2	2		23	1
2	3		23	1
3	1		39	0
3	2		39	1
end

bys School (Classize): keep if _n==1

li, noo sepby(School)
*************

always hoping that there is no school with all missings - in which case
Russel probably wants the missing in his shrunken dataset, anyway...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox
Gesendet: Mittwoch, 16. Dezember 2009 16:47
An: statalist@hsphsun2.harvard.edu
Betreff: st: RE: RE: AW: Creating single values from a nested data file

bysort school : keep if _n == 1 

does what you ask. 

Nick 
n.j.cox@durham.ac.uk 

Russel Wildeman

Thank you Martin

The data look like this 

School Student Classize female 
1	1		35	1
1	2		35	0
1	3		35	1
1	4		35	1
2	1		23	0
2	2		23	1
2	3		23	1
3	1		39	0
3	2		39	1


What I would like is for one of the school-level variables (classize) to
have only one observation per school. Hope I am a bit clearer.

Martin Weiss

Could be a case for -reshape- or -collapse-. For further help, you
should
post a meaningful excerpt of your data.

*From:* Russel Wildeman [mailto:rwildeman@idasa.org.za]

I have education survey data where the data are ordered by school and 
student and more pertinently the variable "school." The data are ordered

by the variable "school" and would give 0 0 0 0 1 1 1 1 etc. I have 
created appropriate school-level variables but the problem is that the 
values of the school-level variables are repeated for the same school, 
whereas I want only one record per school for some of the school-level 
variables. I tried various merging file schemes but none work. Any help 
is highly appreciated

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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