Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[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 <[email protected]>
To
"[email protected]" <[email protected]>
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-.