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
Value weighted returnsDear all, I am analysing stock returns for approximately 700 companies in Japan. My data is ordered…
"variable __000002 already defined" after regression commandWhether executed from the command line or from within the sytax file (do-file), I get, for the follo…
Spregress and esttabHello, I am working with spatial data and trying to export my estimation results from the spregress…
Generating an ID based on multiple variablesHello Statalisters! I am working with the Birth Recode survey of the Demographic and health surveys…
Create a subsample - Conditional, weighted random draw of observations, with repalcementDear Statalisters I want to create a random subsample of my original sample; I am basically drawing…
Subscribe to:
Post Comments (Atom)
0 Response to converting a number to a date
Post a Comment