Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Automating calculating durations from beginning and end dates


From   Clare L Maxwell <[email protected]>
To   [email protected]
Subject   st: Automating calculating durations from beginning and end dates
Date   Tue, 6 Dec 2005 19:38:58 -0600

Hello to the programmers of Statalist.

I have some beginning and end treatment dates, and I would like to calculate durations of treatment.

beginning date vars: cb01dt cb02dt cb03dt cb04dt cb05dt
ending date vars: ce01dt ce02dt ce03dt ce04dt ce05dt
duration vars: cdur01 cdur02 cdur03 cdur04 cdur05

Some of the data:

id cb01dt cb02dt ce01dt ce02dt
E014 04/21/1997 04/30/1997 04/30/1997 04/30/1997
E044 03/17/1998 04/01/1998 04/01/1998 04/01/1998
E046 04/22/1998 04/27/1998 05/07/1998 04/27/1998
E055 08/28/1998 09/04/1998 09/11/1998 09/04/1998
E068 11/06/2000 11/08/2000 11/08/2000 11/20/2000
H006 10/27/1998 11/05/1998 10/30/1998 11/18/1998
M008 08/21/1999 08/19/1999 08/30/1999 08/19/1999
M009 09/17/1999 09/20/1999 09/20/1999 10/03/1999
UW041 04/21/1999 04/21/1999 04/30/1999 04/30/1999
UW046 08/10/1999 08/10/1999 08/19/1999 .
UW047 08/26/1999 08/28/1999 09/05/1999 09/05/1999

The duration of the 1st treatment, cdur01, for E014 is from 4/21/97 to 4/30/97 = 10 days, for example.

I suspect I should use forvalues 1 to 5 to do all the calculations at once, but I am not sure how to proceed. Would you be able to help with this programming task?

Thank you very much. I have really appreciated your help with previous related problems. I look forward to learning a lot more from this one.

Yours truly,
Clare Maxwell
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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