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
Counts Across Unique IdentifierHi Everyone, I am working with a dataset that has foloowing varibales: 1) mrn (unique identifier) …
WTP pack with categorical variable in choice experimentHello, running a mixed logit model and have one categorical variable with three levels/categories. W…
Esttab in a loop and getting table for summary statisticsHello everyone, I have a question about esttab command in a loop and getting the entire output in an…
JDBC connection to Google BigQuery DatabaseDoes anyone here connect to BQ using JDBC successfully? I've been trying to make this work, as I did…
Generating Date IssueHello Statalist, I am having trouble converting dates. I have three date variables (daily_case_date…
Subscribe to:
Post Comments (Atom)
0 Response to format date variable
Post a Comment