<>
If it is all about the results:
*************
clear*
input id Year str10 MathDate MathScore str10 EngDate EngScore
1 2002 "" . "6/21/02" 85
1 2003 "06/20/03" 55 "" .
1 2004 "" . "" .
1 2005 "" . "" .
2 2002 "" . "" .
2 2003 "06/20/03" 40 "" .
2 2004 "05/31/04" 55 "" .
2 2005 "" . "6/15/05" 65
end
compress
list, noobs sepby(id)
/*
Not really necessary...
gen mathdate=date(MathDate, "DMY")
format mathdate %tdMonth_DD,_CCYY
gen engdate=date(EngDate, "DMY")
format engdate %tdMonth_DD,_CCYY
*/
collapse (lastnm) MathScore /*
*/ EngScore, by(id)
list, noobs sepby(id)
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Meryle
Weinstein
Gesendet: Mittwoch, 15. Juli 2009 16:41
An: [email protected]
Betreff: st: Reshaping Data File
I have a dataset that contains 4 records per student representing scores on
tests taken in each year. Each student may or may not have taken the exam
in a particular year, or may have taken the same test in multiple years. I
want to create a dataset that has one record for each student that has each
of the tests taken, regardless of year and if taken multiple times the last
test results.
Here's what the file looks like
Id Year MathDate MathScore EngDate EngScore
1 2002 6/21/02 85
1 2003 06/20/03 55
1 2004
1 2005
2 2002
2 2003 06/20/03 40
2 2004 05/31/04 55
2 2005 6/15/05 65
I thought I could do a reshape wide but there are lots of cells with no
data, plus some cells with multiple data for the same student.
Any help is appreciated.
Meryle Weinstein, Ph.D.
Assistant Director
Institute for Education & Social Policy
New York University
82 Washington Square East, 7th floor
New York, NY 10003
(212) 998-5817
(212) 995-4564 (fax)
www.steinhardt.nyu.edu/iesp
*
* 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/