Reputation: 1
My Stata dataset looks like enter image description here
I would like to remove the days from this variable, as Stata cannot format this into dates to use for my time-series.
Upvotes: 0
Views: 240
Reputation: 37208
. clear
. set obs 1
number of observations (_N) was 0, now 1
. gen problem = "Tuesday. February 1, 2000"
. gen solution = subinstr(problem, word(problem, 1), "", .)
. l
+-----------------------------------------------+
| problem solution |
|-----------------------------------------------|
1. | Tuesday. February 1, 2000 February 1, 2000 |
+-----------------------------------------------+
. gen wanted = daily(solution, "MDY")
. format wanted %td
. l
+-----------------------------------------------------------+
| problem solution wanted |
|-----------------------------------------------------------|
1. | Tuesday. February 1, 2000 February 1, 2000 01feb2000 |
+-----------------------------------------------------------+
Upvotes: 2