Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: date formatting


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: date formatting
Date   Tue, 12 Oct 2010 22:23:47 +0100

This looks like "snap" with mine, except for "DMY" versus "dmy", etc. I don't have the software but I did reach across to the shelves of manuals to establish that in Stata 9 it was lower case. 

Nick 
n.j.cox@durham.ac.uk 

Phil Schumm

On Oct 12, 2010, at 3:55 PM, Rodrigo Briceño wrote:
> Dear Stata users. I'm using stata 9  and windows XP. I need to  
> format a date variable in order to be able to define a panel  
> dataset. My time variable (t) is in the format day/month/year, but  
> the tricky thing is that this format changes for a specific set of  
> observations. From 1-185705 the time variable is dd/mm/yy, but from  
> 185706-360288 the format is mm/dd/yy. I imported the data from excel  
> using insheet.
>
> Before knowing about the existence of the two different formats of  
> time in my variable I used: generate t2=date(t,"dmy"), but then a  
> lot of missing values appeared. What do you think it is plausible to  
> be used so I can get my new time variable (t2) that considers the  
> differences in formats already present in my stata dataset?


     gen t2 = cond(_n<=185705, date(t,"DMY"), date(t,"MDY"))


*
*   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   |   Site index