Instance dos: Dates with a couple-digit and you may four-little finger opinions for year, with all of a few-digit dates in identical century

Instance dos: Dates with a couple-digit and you may four-little finger opinions for year, with all of a few-digit dates in identical century

To do so We put often “19” or “20” ahead of the Y throughout the area of the demand providing you with Stata the order where philosophy arrive

 input str10 day 20 avoid number +------------+ | date | |------------| step one. | 20 | 4. | 04 | +------------+

Two commands, time and you can structure, are acclimatized to move a series go out for the a beneficial numeric date. Throughout these characteristics make an effort to specify how day-big date info is formatted on the sequence. grams. “DMY”) but lower case if you wish to indicate days, minutes or mere seconds (e.grams. “DMYhms”). In the syntax less than, the original demand indeed produces the fresh day adjustable and you can turns the newest sequence towards the correct numeric password towards the date in the question (we.elizabeth. how many days elapsed ranging from January first, 1960 while the date https://getbride.org/es/mujeres-lituanas/ at issue). Our investigation are located in your order go out, day, seasons, so we play with “dmy” (otherwise “DMY”) into the date(…) order (get a hold of less than having details about additional platforms). The next demand platforms brand new numeric worth so when Stata screens this new date, it is for the a questionnaire that’s possible for individuals so you can realize. Remember that while using the listing, and many most other studies display screen purchases, provides viewpoints appear including string schedules, the genuine values held of the Stata was numeric.

Have fun with upper-case to have date, day, and you can year (elizabeth

gen date2 = date(date, "DMY") style date2 %td
+------------------------+ | big date date2 | |------------------------| 1. | 20 | step three. | 21 | 5. | six | +------------------------+

Over, our very own date sequence try formatted go out, month, season, with no character breaking up the various components of our very own time, yet not, Stata can handle a wide variety of forms and ple, the analysis might have been indexed “20-” as well as the orders over would work with no alter. Stata will even deal with schedules your situation in which some entries features separators while some don’t. We could as well as replace the buy where components of the newest go out is actually indexed, the we need to change is the purchase of your own characters accustomed tell Stata which component of brand new go out was where (e.g. year, few days, big date might be specified using “YMD”). Times normally the numeric, such as for instance, 20- plus 20012007. Note that in the event the every numeric schedules is actually registered without separators, you must make sure for the day and you may day unmarried little finger viewpoints (e.g. brand new step one getting January over) features best zeros.

The above analogy thought that the thinking getting season was in fact indexed in the a several digit format (elizabeth.g. 2004), however, that isn’t always the actual situation. The data less than contains times detailed in just a couple digits, provided I understand such schedules emerged sometimes throughout the twentieth (age.grams. 1907) otherwise twenty-first century (elizabeth.grams. 2007), I will share with Stata to treat recent years like they are four little finger values. Such as, having times listed day, day, season, brand new specifcation are “DM20Y”. From the research less than, notice that the very last a couple dates one another have four-fist age (2005 and you can 1999); this is certainly fine – the only limit is the fact that records with a couple-thumb beliefs to possess seasons most of the are from an identical century.

input str14 go out 20 20june1999 prevent record +-------------+ | big date | |-------------| 1. | 20jan07 | dos. | 06sept01 | step three. | 21june04 | 4. | 04 | 7. | 20june1999 | +-------------+

The new demand which will make another numeric date adjustable out-of an excellent sequence variable and you can format the brand new variable which screens due to the fact a romantic date is:

Lascia un commento

Utilizzando il sito, accetti l'utilizzo dei cookie da parte nostra. maggiori informazioni

Questo sito utilizza i cookie per fornire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o cliccando su "Accetta" permetti il loro utilizzo.

Chiudi