Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How to get 4-digit year number


From   "Akihito Tokuhara" <[email protected]>
To   [email protected]
Subject   st: How to get 4-digit year number
Date   Thu, 16 Mar 2006 09:19:02 -0600

Dear all,

I want to strip the dates to get only the 4-digit year number, using the code below:

generate qyear=date(dateinc2,"mdy")
format qyear %d /* This formats the qyear into 12july1987 */
generate byear=yofd(qyear) /* This strips the 4-digit year number from the date */

But if the dates only has 4-digit number, it does not work. Those year numbers become missing
values in new variable.

Is there any way to do all in few codes, including other forms of dates which are non-missing.

Thanks in advance.

Akihito

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index