Statalist


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

st: RE: using reshape command


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: using reshape command
Date   Thu, 9 Oct 2008 15:52:03 +0100

Please don't send attachments to the list. This request and the reasons
why are included in the Statalist FAQ that you were asked to read before
posting. 

It sounds as your identifier is a combination of variables. As the help
for -reshape- explains and exemplifies, the -i()- option of -reshape-
can be a varlist, i.e. also be two or more variables. 

Nick 
[email protected] 

Patrick Mason

I'm looking for some assistance in using the "reshape" command. I've
attached a small sample of the actual data. This is a text file, created
by excel.
 
There are 5 variables: identification, exam_name, exam_date,
exam_outcome, and exam_score.
 
Some obervations have the same idnumber, since an individual may have
taken more than one examination or may have taken the examination
mutiple times (e.g., failing the first time and passing the second or
third time). I want to merge this file with another and use the
examination score in a regression. 
 
 Is there some way to use the "reshape" command (or another procedure)
to create one observation per  identification? For example, if the
individual has taken 5 specialty examinations I'd like to create an
observation that looks the
 following: 
 
 idnumber exam_name1 exam_date1 exam_outcome1 exam_score1 exam_name2
exam_date2 exam_outcome2 exam_score2 ... 

Here's what I've tried (and the error message).

generate edate = date(exam_date, "mdy")       /* change string variable
to numeric variable */

drop exam_date

reshape wide exam_score, i(identification) j(edate)
(note: j = 14715 14827 14911 14995 15086 15184 15359 15450 15548 15639
15730 15912) edate not unique within identification; there are multiple
observations at the same edate within identification.
Type "reshape error" for a listing of the problem observations.
r(9);

*
*   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