Statalist


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

st: RE: Reshaping Data Files


From   "Meryle Weinstein" <[email protected]>
To   <[email protected]>
Subject   st: RE: Reshaping Data Files
Date   Mon, 20 Jul 2009 15:47:21 -0400

Martin and Nick,

It's taken me a few days to get back to this and thanks for your help.  This
is the syntax that worked best, given the number and mix of string and
numeric variables I have in the dataset.

gen mathdate=date(mtdate, "DMY")
format mathdate %tdMonth_DD,_YY
gen engdate=date(etdate, "DMY")
format engdate %tdMonth_DD,_YY

gen date = min(mathdate, engdate) 
bysort newid (date) : ///
replace mscore = mscore[_n-1] if missing(mscore) 
by newid: replace mmeascd = mmeascd[_n-1] if missing(mmeascd) 
by newid: replace mmeascd = mmeascd[_n-1] if missing(mmeascd) 
by newid: replace pflagm = pflagm[_n-1] if missing(pflagm) 


by newid: replace escore = escore[_n-1] if missing(escore)
by newid: replace emeascd = emeascd[_n-1] if missing(emeascd) 
by newid: replace pflage = pflage[_n-1] if missing(pflage) 

by newid: keep if _n == _N

Meryle

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/



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