Statalist


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

st: AW: Reshaping Data File


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Reshaping Data File
Date   Wed, 15 Jul 2009 17:00:10 +0200

<> 

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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Meryle
Weinstein
Gesendet: Mittwoch, 15. Juli 2009 16:41
An: statalist@hsphsun2.harvard.edu
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/



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