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
One way random effects estimationHow do I run one way rand effects estimation on panel data set …
estimate gravity model to calculate potential trade by uisng OLS, REM, FEM, TOBIT and PPLMHi everyone, I'm new here. I am working on my Ms.thesis. the topic related to DETERMINANTS AND POTEN…
Problem running synth_runner commandHi there! I'm having problems running synth_runner command. There are various treated units giving a…
Significance of Cramer's VHi I have a question about the significance of Cramer's V. I calculated the Carmer's V by using C…
Remove combination of quotes and asterisk in variable labelHi all, I have a extrange combination of quotes and asterisk in variable label in my data base... L…
Subscribe to:
Post Comments (Atom)
0 Response to Formatting date variable YYYYMM
Post a Comment