Hi,
I would appreciate your help with formatting date variables. I use Stata 15.
I would like to get YYYYMM-variables in a date formate and I used following syntax:
foreach var of varlist {
format `var' %12.0g
tostring `var', gen(junk`var')
gen junk`var'2 = mofd(date(junk`var', "YM"))
format junk`var'2 %tm
}
Then the result looks like this:
2010m1
2010m2
2010m3
2010m4
2010m5
2010m6
2010m7
2010m8
2010m9
201010
I wonder how I can get this result:
201001
201002
201003
201004
201005
201006
201007
201008
201009
201010
I have not found any help in the Stata manuals about working with dates and times.
Related Posts with Formatting date variable YYYYMM
Help with Stata's GraphsHi I'm trying to build a Graph on Stata but the variability of my Data is very high. I need to buil…
Analyzing two time points with regressionI am analyzing data with the mental health component score (measured 0-100) for 4500 individuals. Th…
Attrition and OLS estimatosHow can I prove that the attrition bias affects or does not affect my OLS estimator? Can I do it wit…
Reg without constant termHi, I know that when I estimate a regression with fixed effects the constant term should not be inc…
longitudinal population survey dataHello, I have a longitudinal population survey data. This is actually my first time working with su…
Subscribe to:
Post Comments (Atom)
0 Response to Formatting date variable YYYYMM
Post a Comment