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]
st: Setting a reference value by rows for calculating differences
From
CHERYL BARNABE <[email protected]>
To
[email protected]
Subject
st: Setting a reference value by rows for calculating differences
Date
Fri, 17 Jun 2011 00:45:26 -0600
Hi there, trying to calculate the elapsed time from the baseline (or 1st visit) for each subject to subsequent follow-up visits, not the prior visit, but can't figure out the command to keep the first entry per subject as the reference, and need the visitmonth variable for reshaping purposes. Does anyone know how to do this? Thanks a million
study_id visitdate visitorder visitmonth visittime
01-1 30nov2006 1 0
01-1 12feb2007 2 74
01-1 01may2007 3 78
01-1 14dec2007 4 227
01-1 30may2008 5 168
01-1 21nov2008 6 175
01-1 08may2009 7 168
01-10 21jun2007 1 0
01-10 13sep2007 2 84
01-10 27mar2008 3 196
01-10 11sep2008 4 168
01-10 13jan2009 5 124
01-10 02apr2009 6 79
by study_id: gen visittime=(visitdate-visitdate[_n-1])
by study_id: generate visitmonth=(visitdate-visitdate[_n==1])
*
* 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/