Dear statalist,
I need to convert numbers to dates (format: 1/1/2019). The numbers are a string variable, and are in the following format (mdy):
datenumber
12232019
12202019
12192019
12192019
12192019
12182019
12182019
12162019
10122019
05122019
05122019
03122019
11252019
11182019
11182019
11152019
06112019
...
Notice that the months and days always exist of two digits (so sometimes it starts with a zero).
I used the code:
gen date= date(datenumber, "MDY")
But only missing values were generated. I would be very thankful if you can provide me with guidance or code to solve this issue. Eventually, I want the dates to be in the format: m/d/y: so 1/1/2019. Thank you very much in advance.
Floris Bedkom
Related Posts with converting a number to a date
Barro Regression: 3SLS with panel dataHello! I am a student of a Master in Economics and I am new here but I hope that you can help me wit…
gen mean with if statementsI am fairly new to STATA, and need to create a moving average for my data. (I cannot use tsset for t…
Shading AUC on ROC curve?Is it possible to shade with color the area under the curve on an ROC curve in stata? I can't find a…
command for recognizing the co-residing parents and sons/daughtersHow can I recognize co-residing parents and sons/daughters in the Employment & Unemployment Surv…
Clear results saved in r()Dear All, I am trying to clear the r()-saved results left by the previous command before going to t…
Subscribe to:
Post Comments (Atom)
0 Response to converting a number to a date
Post a Comment