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]

RE: st: Date conversion question


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: Date conversion question
Date   Thu, 10 Mar 2011 13:29:39 +0000

Please note that Scott's diagnosis of this problem looks correct; and so mine was incorrect. Sorry about that, 

Nick 
[email protected] 

Scott Merryman

clear
set obs 1
gen double date = 20070331
gen mydate = date( string(date,"%12.0g"), "YMD")
format mydate %d
l

See -help dates and times-

On Wed, Mar 9, 2011 at 2:03 PM, Amy Dunbar
<[email protected]> wrote:

> Sorry to bother the list with a trivial date question, but I can't figure out I read out how to solve my problem.
> How do I get a date variable (rssd9999) to show the actual date instead of 2.01e+07?
>
> I tried to pull out the year with
>                          gen year = year(rssd9999)
> but the generated variable is ".", so the commands suggested in the date and time help file don't work for this variable.
>
> I show the results of tab and codebook for this variable below.
>
> .               tab rssd9999
>
>                 Date      Freq.     Percent                Cum.
>
>                 2.01e+07              1,218     4.47        4.47
>                 2.01e+07              5,689     20.88     25.35
>                 2.01e+07              1,208     4.43        29.78
>                 2.01e+07              5,669     20.80     50.58
>                 2.01e+07              1,208     4.43        55.01
>                 2.01e+07              5,516     20.24     75.26
>                 2.01e+07              1,215     4.46        79.71
>                 2.01e+07              5,528     20.29     100.00
>
>                 Total      27,251   100.00
>
> . codebook rssd9999
>
> ----------------------------------------------------------------------------------------------------------------------
> rssd9999                                                                                                          Date
> ----------------------------------------------------------------------------------------------------------------------
>
>                   type:  numeric (double)
>
>                  range:  [20070331,20081231]          units:  1
>          unique values:  8                        missing .:  0/27251
>
>             tabulation:  Freq.  Value
>                           1218  20070331
>                           5689  20070630
>                           1208  20070930
>                           5669  20071231
>                           1208  20080331
>                           5516  20080630
>                           1215  20080930
>                           5528  20081231
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index