Statalist


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

Re: AW: st: Re: Re: dates in stata


From   lschoele@rumms.uni-mannheim.de
To   statalist@hsphsun2.harvard.edu
Subject   Re: AW: st: Re: Re: dates in stata
Date   Wed, 01 Apr 2009 16:37:50 +0200

Hi,

gen dateval=date( event_date, "dmy")
worked.

Thanks for your help


Zitat von Martin Weiss <martin.weiss1@gmx.de>:


<>

My thought is that the "20" is unnecessary as it is useful for 2-digit years
only. See

*************
help dates_and_times, mark(twodigit)
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von E. Paul Wileyto
Gesendet: Mittwoch, 1. April 2009 00:43
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: Re: Re: dates in stata

Did this date function work the same way in Stata 8 or 9?... or was it
more limited?

I suggested to Lisa other notations such as

gen dateval=date( event_date, "D M 20Y")

Any thoughts?

Paul

Martin Weiss wrote:
<>

Lisa requested additional information in a private email to me. She
said that Paul`s help did not solve her problem and that she ended up
with all missings for the string-to-date transformed variable. I
recreate her prob below, it works perfectly for me...

****
clear*
inp str15 company_id str20 event_date
Nintendo  "9 May 2006        "
Palm      "18 May 2005       "
Apple     "23 October 2001   "
Apple     "7 September 2005  "
Apple     "11 January 2005   "
Apple     "6 January 2004    "
Apple     "5 September 2007  "
Apple     "9 January 2007    "
Apple     "7 August 2007     "
Apple     "1 May 2001        "
Apple     "15 January 2008   "
Apple     "14 October 2008   "
LG        "11 December 2006  "
LG        "11 February 2008  "
Pioneer   "7 January 2008    "
end

compress
gen dateval=date(event_date, "DMY")
format dateval %td
sort dateval
l
****



HTH
Martin
_______________________
----- Original Message ----- From: "Martin Weiss" <martin.weiss1@gmx.de>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, March 31, 2009 11:28 PM
Subject: st: Re: dates in stata


<>

Lisa may also profit from Nick`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0006

The essential point here is that you read in your dates as strings,
and when you fire up -sort- it sorts like you would sort, say,
surnames: according to the alphabet.

Once you have applied the string-to-date functions recommended in
this thread and described under -help dates_and_times,
mark(str2num)-, dates are defined as number of days from 1/1/1960.
This allows you to sort a numeric variable, although it is still
displayed as 1/8/2008, according to the format you apply to the new
variable...

HTH
Martin
_______________________
----- Original Message ----- From: <lschoele@rumms.uni-mannheim.de>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, March 31, 2009 10:44 PM
Subject: st: dates in stata


Hello Statalist,

I am using Stata for event study. I entered all my variables and
observations.
Regarding my variable "date" I have a problem. When I use "sort
date", stata  sorts the date shown above:date
01 April 2002
01 April 2003
01 April 2004
01 April 2005
01 April 2008
01 August 2000
01 August 2001
01 August 2002
01 August 2003
01 August 2005
01 August 2006
01 August 2007
01 August 2008
01 December 2000
01 December 2003
01 December 2004
01 December 2005
01 December 2006
01 February 2000
01 February 2001
01 February 2002
01 February 2005
01 February 2006
01 February 2007
01 February 2008
01 July 2002
01 July 2003
01 July 2004
01 July 2005
01 July 2008
01 June 2000
01 June 2001
01 June 2004
01 June 2005
01 June 2006
01 June 2007
01 March 2000
01 March 2001
01 March 2002
01 March 2004
01 March 2005
01 March 2006
01 March 2007
01 May 2000
01 May 2001

I can tell that stata sorts by the first letter of the month. Do I
have to use a special format for the date? I also tried the format
01.04.2002, but that gives me the same sortation shown above.

Can anyone help me?

Best regards
Lisa



*
*   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/


*
*   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/


*
*   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   |   What's new   |   Site index