Try
forvalues i = 1/2 {;
local j=`i'+1
gen days`i'`j' = date`j'-date`i';
};
cheers,
Jeph
Hugh Colaco wrote:
> 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/
>
>
*
* 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/