Hello,
i have a date variable in my dataset which is type "long" and formated in the following way:
date
28jun2017
04oct2017
09sep2014
11jan2016
I would like to change the formatting to make it look like this:
date
28-jun-2017
04-oct-2017
09-sep-2014
11-jan-2016
I tried this before:
tostring date, format("%09.0f") replace
gen date1=substr(date,1,2)+"-"+substr(date,3,9)
as a first step for the first "-"
but the "tostring" command converts the variable in numbers only, and the date information is somehow lost.
If i try tostring date, format("%09.0f") replace, the variable suddenly looks like this:
date
000020998
000021096
000019975
000020464
I hope someone can help me ! thank you !
PS: i tried to display the data with dataex but that also just gave me really weird looking values for the date variable.
Related Posts with format date variable
What we should do when the result is only significant to one country but the whole sample?In a staggered Difference-in-Differences setting, my static setting is: Array On the result table …
cannot compute an improvement -- discontinuous region encounteredHi, I'm doing ordered logistic regression with panel data set, and ran across with the error message…
pweights in panel data to adjust for populationI am working on a panel data with a data structure like (I have some other variables but I am only p…
Defining the cutoff in regression discontinuityHi there, I am trying to run a regression discontinuity based upon the dataset found below. However…
What we should do when the coefficients of variables of interest quite different from that of whole sample?I have a staggered Difference-in-Differences setting as below when examining the impact of laws impl…
Subscribe to:
Post Comments (Atom)
0 Response to format date variable
Post a Comment