To achieve this I create either “19” or “20” in front of the Y regarding the part of the command that gives Stata your order where the opinions are available
type in str10 day 20 end number +------------+ | big date | |------------| step 1. | 20 | 4. | 04 | +------------+
One or two requests, big date and you can style, are acclimatized to move a string big date to your an effective numeric time. Within these characteristics attempt to indicate how the date-big date information is formatted on the sequence. g. “DMY”) but lower case if you want to indicate days, moments otherwise seconds (e.grams. “DMYhms”). Regarding the sentence structure less than, the original command actually yields the date changeable and you may transforms the fresh string on the right numeric code into the go out within the question (we.age. the number of weeks elapsed ranging from January very first, 1960 while the date concerned). Our research can be found in the transaction big date, few days, seasons, so we use “dmy” (otherwise “DMY”) in the day(…) order (see below to have facts about more formats). The following command platforms new numeric worthy of so as that whenever Stata screens the newest date, it’s for the a form which is easy for people to help you discover. Remember that while using record, and many almost every other study display orders, produces opinions that look like string schedules, the genuine thinking held by Stata try numeric.
Have fun with upper-case having date, times, and you may year (elizabeth
gen date2 = day(big date, "DMY") structure date2 %td
+------------------------+ | time date2 | |------------------------| 1. | 20 | step 3. | 21 | 5. | 6 | +------------------------+
Over, all of our date vГ©alo sequence is actually formatted date, week, seasons, and no reputation separating various components of all of our time, however, Stata can handle many forms and you can ple, our data could have been listed “20-” additionally the requests above would work without any alter. Stata will also manage dates the actual situation where particular entries keeps separators while some do not. We can as well as alter the purchase where in fact the components of the brand new big date try listed, the we have to change ‘s the purchase of the characters used to share with Stata and therefore component of this new go out was where (elizabeth.grams. year, week, day might be specified playing with “YMD”). Dates can every numeric, for example, 20- and even 20012007. Note that in the event that all numeric schedules was entered in the place of separators, you should make certain that throughout the day and you may week solitary thumb philosophy (age.g. this new step one having January more than) features top zeros.
The above example assumed your beliefs getting seasons was listed inside the a four little finger format (e.g. 2004), however, this is simply not constantly the truth. The data below contains dates detailed with only a couple of digits, provided that I know such times came often throughout the twentieth (elizabeth.g. 1907) otherwise 21st century (age.grams. 2007), I’m able to tell Stata to alleviate recent years as if they is actually five fist viewpoints. Eg, having schedules listed day, day, season, new specifcation was “DM20Y”. Regarding the study below, see that the final one or two times both have four-thumb age (2005 and you will 1999); this is good – truly the only limitation is the fact that the entries having a few-digit beliefs to have year all come from an identical century.
input str14 go out 20 20june1999 prevent listing +-------------+ | date | |-------------| step one. | 20jan07 | dos. | 06sept01 | step three. | 21june04 | 4. | 04 | seven. | 20june1999 | +-------------+
New command to make a unique numeric big date varying of a good sequence varying and you will structure brand new varying so it displays since the a date try: