To accomplish this We create sometimes “19” otherwise visita esta pГЎgina “20” in front of the Y about the main order providing you with Stata the transaction where in actuality the opinions arrive
input str10 day 20 prevent listing +------------+ | go out | |------------| step 1. | 20 | cuatro. | 04 | +------------+
One or two requests, time and you can structure, are acclimatized to move a series date into a good numeric time. In these services try to establish how the day-date info is formatted regarding the sequence. g. “DMY”) however, lower-case if you’d like to establish occasions, minutes otherwise moments (age.grams. “DMYhms”). In the sentence structure lower than, the initial demand actually stimulates the fresh new date adjustable and you may converts brand new sequence to the proper numeric code into date inside the concern (we.e. the number of days elapsed between January initially, 1960 in addition to day under consideration). The research are in the transaction date, few days, year, so we fool around with “dmy” (otherwise “DMY”) inside day(…) demand (select below for information regarding more forms). Another command formats the latest numeric well worth to ensure when Stata screens the big date, it’s during the a form that’s simple for people to help you see. Note that while using the record, and lots of most other research screen commands, supplies thinking that look like string schedules, the true viewpoints held because of the Stata is actually numeric.
Fool around with upper case to own time, week, and you can 12 months (elizabeth
gen date2 = go out(day, "DMY") format date2 %td
+------------------------+ | big date date2 | |------------------------| step one. | 20 | step 3. | 21 | 5. | 6 | +------------------------+
A lot more than, the date string was formatted big date, few days, seasons, without reputation breaking up the various areas of the go out, but not, Stata can handle numerous formats and ple, the analysis could have been indexed “20-” as well as the instructions above works without the alter. Stata will deal with dates happening where some records possess separators while some don’t. We can together with replace the buy where the components of the new date was listed, most of the we need to change ‘s the purchase of letters familiar with give Stata and that component of the latest date are in which (e.g. 12 months, times, time will likely be given using “YMD”). Schedules can every numeric, such as for example, 20- as well as 20012007. Observe that in the event the most of the numeric times was joined instead separators, you should make sure that throughout the day and month unmarried thumb viewpoints (e.g. this new step one to have January significantly more than) keeps leading zeros.
The aforementioned analogy thought that the values having 12 months was basically listed in the a several fist structure (elizabeth.g. 2004), however, this is simply not always your situation. The content less than contains times listed with only a couple of digits, provided I am aware such times emerged both on twentieth (e.g. 1907) otherwise 21st century (e.g. 2007), I can share with Stata to treat many years like they are four little finger viewpoints. Such as for example, getting dates listed day, week, seasons, the brand new specifcation is actually “DM20Y”. On research below, note that the final two dates each other include five-finger many years (2005 and you can 1999); this will be okay – really the only limitation is the fact that records which have a couple-fist viewpoints having year all come from a similar century.
type in str14 go out 20 20june1999 prevent number +-------------+ | day | |-------------| step 1. | 20jan07 | 2. | 06sept01 | step 3. | 21june04 | cuatro. | 04 | 7. | 20june1999 | +-------------+
The newest command to help make a new numeric big date changeable off an effective sequence variable and structure brand new varying this displays while the a romantic date is actually: