Statalist


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

st: RE: extracting month and year from a date variable


From   "Ariel Linden, DrPH" <ariel.linden@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: extracting month and year from a date variable
Date   Thu, 27 Aug 2009 19:25:19 -0700

Thanks, all. These suggestions work perfectly. I would like to also thank
Mingfeng Lin who responded to me off-line.

Ariel

Date: Thu, 27 Aug 2009 00:52:22 -0400
From: "Mert Demir" <demirmrt@gmail.com>
Subject: st: RE: extracting month and year from a date variable

Try this:

g mydate=date(date, "MDY")  /* Second "date" is the 'original date
variable'. 
format mydate %td
g dm=mofd(mydate)
format dm %tm
drop mydate

Hope it works.

Best,

*
*   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   |   What's new   |   Site index