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: AW: using dates with inrange()


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: using dates with inrange()
Date   Mon, 19 Apr 2010 17:03:49 +0200

<> 


I bet -replace date = date(date, "MDY")- leads to "type mismatch"...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von David Souther
Gesendet: Montag, 19. April 2010 16:49
An: statalist@hsphsun2.harvard.edu
Betreff: st: using dates with inrange()

I'm trying to figure out how to create a variable that coded according
to whether it falls in certain time periods in my dataset.  So, I've
got data like

input date
"03/29/2000"
"04/21/2001"
"08/07/2002"
"09/01/2001"

and I format the dates with

replace date = date(date, "MDY")
format date %td

but I want an indicator that is 1 if the dates are in the range Aug.
15, 1999 to Aug. 14, 2000 and indicator = 2 if in the range Aug. 15,
2000 to Aug. 14, 2001 and so on, but I cannot figure out how to get
inrange() to work (or some other method to create this indicator):

generate ind = .
replace ind = 1 if inrange(date, 15aug1999, 14aug2000)
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index