Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Σχετ: st: getting Stata to understand the format of the dates


From   Tzaloupas Dimitrov <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Σχετ: st: getting Stata to understand the format of the dates
Date   Tue, 5 Feb 2013 19:00:38 +0000 (GMT)

thanks Nick

----- Αρχικό μήνυμα -----
Απο: Nick Cox <[email protected]>
Προς: [email protected]
Κοιν.: 
Στάλθηκε: 7:31 μ.μ. Τρίτη, 5 Φεβρουαρίου 2013
Θέμα: Re: st: getting Stata to understand the format of the dates

Note that this will work too:

gen emonth1=mofd(date(dates, "MDY"))

Note also -- and this is not widely known -- that -daily()- is a
synonym for -date()-.

There is some history there. Apart from say years -- which don't need
special treatment -- Stata had at first just one kind of date, daily
dates, and -date()- was a function to take in string daily dates and
emit numeric daily dates. The name -daily()- does not carry that
ambiguity.

However, -monthly()- is in the same kind of way a function to take in
string monthly dates and emit numeric monthly dates. It is _not_ a
conversion function to take in other kinds of dates and emit numeric
monthly dates, and as Jeph explains, you need -mofd()- for that
purpose.

Nick

On Tue, Feb 5, 2013 at 6:14 PM, Jeph Herrin <[email protected]> wrote:
> This will produce a date variable:
>
>  gen edate1=date(dates,"MDY")
>  format edate1 %td
>
> and if you want the month
>
>  gen emonth1=mofd(edate1)
>  format emonth1 %tm
>
> Then, you would declare your data time series data:
>
>  tsset emonth1

On 2/5/2013 1:10 PM, Tzaloupas Dimitrov wrote:

>> I have a column with this date format
>>
>>
>>  dates
>> 01/07/2009
>> 01/08/2009
>> 01/09/2009
>> 01/10/2009
>> 01/11/2009
>> 01/12/2009
>> 01/01/2010
>> 01/02/2010
>> 01/03/2010
>> 01/04/2010
>> 01/05/2010
>> 01/06/2010
>> 01/07/2010
>>
>>
>> HOw can i get stata understand that this is a time series data set of
>> monthly observations?
>>
>> I tried something like
>>
>> gen edate1 = monthly(dates, "DMY")
>>
>> but it seems that it does not work
>>
>> Any suggestions?
>>
>> I use 64 bit Stata 11
*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index