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, is already up and running.

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

Re: st: Need help programming for dates in Stata

From   Jeph Herrin <>
Subject   Re: st: Need help programming for dates in Stata
Date   Tue, 05 Mar 2013 22:18:39 -0500


On 3/5/2013 2:42 PM, Nick Cox wrote:


On Tue, Mar 5, 2013 at 7:39 PM, Jeph Herrin <> wrote:

forv y=2009/2012 {
    gen used_`y'= inrange(`y',yofd(startdate),yofd(stopdate))


On 3/5/2013 1:43 PM, Michael Stewart wrote:


I have a list of start and stop dates for medications
I am trying to find if there is way to classify  them to specifically
say if they are used in particular years

Med  Start date    Stopdate
xxx    11/12/2009    11/12/2012
yyy      .               1/2/2010
zzz    1/1/2009      .

I want to create four  variables Used_2009   used_2010    used_2011

The criteria is
1)If medication is  used even for a day in a year, it is considered to
be used for that year
2)If the start date is blank, then it is deemed to be used from a much
prior day
3)If ending date is blank/missing then  that medication is currently
*   For searches and help try:

*   For searches and help try:

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