Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: RE: RE: RE: RE: Combining multiple observations by an ID variable


From   Clyde B Schechter <clyde.schechter@einstein.yu.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: RE: RE: Combining multiple observations by an ID variable
Date   Thu, 14 Jun 2012 15:30:19 +0000

A consensus appears to have emerged, now including Claude, that -reshape wide- isn't possible for his data set.  He seems to remain daunted at the task of calculating what he needs from his long-form data set.

One more command that may prove useful to Claude is -collapse-.

For example, if the presence of a certain condition is coded 0 = no, 1 = yes, and varies within patient over visits, a simple way to get a one-record-per-patient data set that says whether the patient ever had it is:

collapse [other interesting variables] (max) condition [other interesting variables], by(patient_id)

The resulting data set will have one record per patient, and in this data set condition will be 1 if the patient ever had the condition, and 0 otherwise.  And, if desired, he can rename the variable either in the -collapse- command or afterward. See -help collapse-.



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