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
Why the enhanced module of lclogit (lclogit2) does not converge?Dears I am estimating latent class models and i have some problems with the command lclogit2. Appar…
Insignificant F statistics, R square approximately equal to 0. Insignficant t statisticsDear Stata list members Advance apologies for asking a naive question. I conducted an analysis to c…
Non parametric of ManovaHi! The title is the question. Is there a non parametric counterpart of Manova? I found that resampl…
Appending ColumnsI have 4 different variable names that I want to collapse to a single column, though keep the identi…
Exporting confidence intervals that loop through all vars in an excel formatFor each of my regional data files, I am trying to export confidence interval tables in a csv file. …
Subscribe to:
Post Comments (Atom)
0 Response to Formatting date variable YYYYMM
Post a Comment