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]
Re: st: Stata date
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Stata date
Date
Tue, 9 Apr 2013 17:37:47 +0100
It's a good answer. However, -summarize- is just being a robot here.
Consider this
dopey example:
. sysuse auto
. format mpg %td
. codebook mpg
-----------------------------------------------------------------------------------------
mpg
Mileage (mpg)
-----------------------------------------------------------------------------------------
type: numeric daily date (int)
range: [12,41] units: 1
or equivalently: [13jan1960,11feb1960] units: days
unique values: 21 missing .: 0/74
mean: 21.2973 = 22jan1960 (+ 7 hours)
std. dev: 5.7855
percentiles: 10% 25% 50% 75% 90%
14 18 20 25 29
15jan1960 19jan1960 21jan1960 26jan1960 30jan1960
. su mpg, format
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
mpg | 74 22jan1960 06jan1960 13jan1960 11feb1960
If -mpg- is a daily date, then the mean, min and max are too. However,
the standard deviation of a daily date is not itself a daily date, as
it is a number in days, regardless of the date scale. That is why I
prefer -codebook- here.
Nick
[email protected]
On 9 April 2013 17:31, Rebecca Pope <[email protected]> wrote:
> Ray,
> See -help summarize-. You'll notice that the -format- option will
> cause the results to be displayed using the same format as the
> variable, in your case %td.
>
> Regards,
> Rebecca
>
> On Tue, Apr 9, 2013 at 11:22 AM, Ray Hawkins <[email protected]> wrote:
>> Hi,
>>
>> My date is stored in %td format, e.g.,
>>
>> mydate
>> 19aug2005
>>
>> When I summarize mydate:
>>
>> sum mydate
>>
>> it produces results like the following.
>>
>> Variable | Obs Mean Std. Dev. Min Max
>> -------------+--------------------------------------------------------
>> buydt | 9261737 16785.61 9.022221 16771 16801
>>
>> Can I display the summary results in a specific format such as %td? This is
>> because the data is too big and sorting takes long time to see the min and
>> max dates. Or, is there a table that matches numbers to actual dates? The
>> help file says that:
>>
>> %td dates 01jan0100 to 31dec9999 (integers -679,350 to 2,936,549)
>>
*
* 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/