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
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: Date conversion question
Date
Wed, 9 Mar 2011 14:25:49 -0600
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-
Scott
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
>
> Amy
>
>
>
> Amy Dunbar
> University of Connecticut
> School of Business
> Department of Accounting
> 2100 Hillside Road Unit 1041
> Storrs, CT 06269-1041
>
> cell 860-208-2737
> [email protected]
>
>
*
* 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/