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: Combining dates in Stata
From
Christopher Baum <[email protected]>
To
"[email protected]" <[email protected]>
Subject
re: st: Combining dates in Stata
Date
Thu, 26 Jan 2012 15:33:51 -0500
<>
I have two time variables in my dataset - one for year and one for month.
Both of these variables are numeric with Year containing four-digit
year values and month is a two-digit values ranging from 1 to 12.
I would like to combine the Year and month variables into one a time
variable to allow me to work with the dataset as a panel. How do I
recode (or replace) the Year and Semester month to create one.
Specifically, I would like to have one variable that reads 1/2000 for
january 2000, or 2000m1... I do not really mind the format!
Easily solved with help datetime_functions:
g yearmo = ym(year, month)
format yearmo %tm (or whatever you prefer)
tsset unitid yearmo
Kit
Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* 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/