Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Days between dates using -forvalues-


From   "Hugh Colaco" <hmjc66@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: Days between dates using -forvalues-
Date   Sun, 14 May 2006 15:32:16 -0400

Hi,

I'm trying to get the no of days between dates for several dates. I
want to create variables days12 and days23 (see example below). I
tried to run the foll program

forvalues i = 1/2 {;
gen days`i'`i+1' = date`i+1'-date`i';
};

but I get days11 and days22 as the new variables and the values are 0.

Thanks,

Hugh


date1	 date2	   date3	        days12         days23
12/13/1995  5/17/1996 6/14/1996	           156	28
6/22/1999	7/16/1999		             24	
7/3/1996	9/25/1996	10/11/1996             84	16
3/29/1995	6/23/1995	  7/12/1995             86	19
11/9/1994	5/5/1995	  8/17/1995             177	104
9/22/1998	11/10/1998 11/24/1998	49	14
9/19/1996	3/25/1997	   5/27/1997	187	63
9/8/1994	10/18/1994		40	
5/13/1993	7/13/1993	     8/6/1993	61	24
6/30/1998	7/23/1998	   7/29/1998	23	6
12/17/1999  1/18/2000   2/7/2000	                32	20

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index