I am using Stata V10 and have a dataset with repeated blood glucose
measurements per day. The data are ordered by patient id (pid) and
within patients by the date of the glucose readings (datestamp). In
other words, there is one record per patient/blood glucose reading.
I would like a new dataset with one record per patient id/date but
with one variable for each reading that day. For example, in a month
with thirty days where a patient took at least one blood glucose
measurement per day, there would be thirty records. There would be a
variable corresponding to each blood glucose measurement.
The following data indicate what I currently have and what I would
like to have. I have put a blank line between groups to make the data
more readable but these breaks do not exist in the Stata dataset.
This strikes me as a -reshape- problem but the dates are duplicates so
-reshape- fails. If this is not a reshape problem I don't even know
what to call it to search the Statalist archives.
Any suggestions/pointers are welcome.
ORIGINAL DATA
pid site datestamp bglevel enrolldate fuploaddate
1424 PBCI 10jan2006 253 09jan2006 13jan2006
1424 PBCI 10jan2006 185 09jan2006 13jan2006
1424 PBCI 10jan2006 252 09jan2006 13jan2006
1424 PBCI 13jan2006 223 09jan2006 13jan2006
1424 PBCI 13jan2006 173 09jan2006 13jan2006
1424 PBCI 13jan2006 156 09jan2006 13jan2006
1428 PBCI 10jan2006 208 11jan2006 11jan2006
1428 PBCI 10jan2006 226 11jan2006 11jan2006
1428 PBCI 10jan2006 242 11jan2006 11jan2006
1428 PBCI 10jan2006 279 11jan2006 11jan2006
1428 PBCI 11jan2006 222 11jan2006 11jan2006
1428 PBCI 11jan2006 184 11jan2006 11jan2006
1428 PBCI 11jan2006 204 11jan2006 11jan2006
NEWLY SHAPED DATA
pid site datestamp enrolldate fuploaddate bg1 bg2 bg3 bg4
1424 PBCI 10jan2006 09jan2006 13jan2006 253 185 252 .
1424 PBCI 13jan2006 09jan2006 13jan2006 223 173 156 .
1428 PBCI 10jan2006 11jan2006 11jan2006 208 226 242 279
1428 PBCI 11jan2006 11jan2006 11jan2006 222 184 204 .
Thanks,
Alan
*
* 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/