![]() ![]() But then it just sums up the frequencies, but I cant figure out how to subtract them. If you need to work backwards from an end date and age, you could do it with multiple invocations of date. I tried using gen var3 var2 - var1, but somehow then it subtracts the IDs and not the frequencies. It doesnt, so you dont, if the days offset crosses a month boundary in a different length month. If subtracting used the opposite order, then youd get back to your starting point. ![]() So, the main workhorse here is monthly(). The first can be calculated by looking at the first 7 characters of your longer string and the second can be calculated by combining a month and a year, with needed trickery to extract a substring and to convert the year on the fly to a string. Here, however, I go back to first principles - what you want is the difference between two monthly dates. Stata has recently added many functions to do with date differences (including age and birthday problems) and if you are using Stata 18 (which is assumed unless you state otherwise) they are accessible to you. So here is some technique but using more informative variable names. Here it seems that you have a datetime as a string variable, a month as another string variable, and a year as a numeric variable. Its main use in data analysis would be identifying which side of some specified, usually somewhat arbitrary, age limit (21 to drink alcohol in the US, 65 to get Medicare in the US, 12 to get a Covid vaccine in the US) people lie on.We ask you to help us to help you by not giving screenshots but by using dataex to show a data example we can use directly. In fact, age truncated the the integer part, which is the colloquial use of the word age, and what the age() function calculates, is, as seen by this example, quite coarse and inaccurate. If you want to make it a bit more accurate, allowing for leap years, you can divide instead by 365.25 (which is the usual practice in my field, epidemiology). From, Ravindran, Kiron <> To, statalist <> Subject, st: calculating age / tenure Date, Wed.That difference would be picked up by calculating the difference in days and dividing by 365. But so is a person born 7 October 2010-even though the latter has lived 364 days longer than the former. In my data set, if the child is 15 months old, the age displayed is 15 months. I then calculate the age by subtracting the date of birth from the date of survey. I have another date variable which opens up the calendar to enter the date of birth. A person born on 6 October 2011 is considered ten years old using the age function. I have a date variable which opens up the calendar to enter date of survey. Where I am located, today is 6 October 2021. I have generated daysincecon using : gen daysincecon (episodestartdt - concussonset) and get the results below. ![]() I am trying to subtract one date to the other but am getting it in milliseconds, I believe. For example, if the interview date was 13 Sept 2011 and a birthdate is such that and Age (date1 - date2) / 365.25 11.68515 then this person is 11 years and 8 months (12.68515 8.22) or another example interview date was and birthdate is (Age 9.946612) so this person is 10 years and 11 months (12. Taking the difference in years and dividing days by 365 to get years is actually much more accurate for most purposes than using the age() function. In my data set the dates are in the format: 17dec2016 00:00:00. ![]() The date variable (BIRTHDATE) in my dataset is formatted as DDMMMYYYY and Ive trying to create an age integer variable from it like 21. Gestational age can help your doctor provide the best prenatal care for you and your baby and monitor your baby. If you underwent in vitro fertilization, gestational age can be calculated from the date of embryo transfer and the age of your embryo. Sorry for crashing the party, but I can't resist commenting on this. makes an exponent ln(var) or log(var) takes the natural log. Calculate Age from Birth Date Posted 02-07-2018 01:07 PM (47907 views) Ive seen some other threads about this but havent been able to get my code to work based on those. Gestational age is measured in weeks, from the first day of your last period to the current date. I used the daily but what i wanted in this example in years, I try to divided days by 365 but sure not completely accurate Input str10 Stkcd str24 EstablishDate str20 ListedDate Input str10 Stkcd str24 Rptdt str20 Fenddt ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |