Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Fwd: Creating date variables using loops


From   Lars Folkestad <lfolkestad@health.sdu.dk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Fwd: Creating date variables using loops
Date   Thu, 4 Oct 2012 12:18:33 +0200

> Morning List
> 
> I have a dataset containing id startdate stopdate but want to create 1 variable for every day inbetween. The duration is not The same pr id.
> 
> I thought that since i increase by one unit (=1day) each time it would be easily done using a loop. I have not used loops before and need coding help:
> 
> foreach var in id startdate stopdate {
> gen `day'= but what to write here seening i want The number of variables from start till stop. 
> 
> Mvh
> Lars Folkestad
> 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index