Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: generating year for a given age
From
Debs Majumdar <[email protected]>
To
[email protected]
Subject
Re: st: RE: generating year for a given age
Date
Tue, 4 May 2010 14:18:29 -0700 (PDT)
Thanks. And I am going to look into the date_and_times just to be thorough when generating then new variables. Yes, you are correct about the reverse characters.
Debs
----- Original Message ----
From: Martin Weiss <[email protected]>
To: [email protected]
Sent: Tue, May 4, 2010 1:56:22 PM
Subject: st: RE: generating year for a given age
<>
This is a cheap first shot. You want to dig deeper into -help
dates_and_times- to get all the leap years and stuff into this. Am I correct
that your "dateint" has the first two characters reversed?
***********
clear*
inp byte id str13 dateint age_bl
1 "7242003" 81.00753
2 "6132003" 89.99042
3 "4222004" 84.70363
4 "1092005" 71.01163
5 "9042003" 65.36345
end
compress
list, noo
gen str15 newdate= /*
*/ reverse(substr(dateint,1,2))+ " " + /*
*/ substr(dateint,3,1)+ " " +substr(dateint,4,.)
gen mydate=date(newdate, "DMY")
form mydate %tdMon_DD,_CCYY
drop dateint newdate
gen birthday=mydate-age_bl*365
format birthday %td
gen yearwhenforty=yofd(birthday+40*365)
l
***********
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Debs Majumdar
Sent: Dienstag, 4. Mai 2010 22:38
To: [email protected]
Subject: st: generating year for a given age
Hi,
I have a dataset where I have the date of interview and the
corresponding age at that time (age_bl). I want to create two variables of
of this: 1) date of birth and 2) year when age was 40 for the participants.
| id dateint age_bl |
|--------------------------------------|
1. | 1 7242003 81.00753 |
2. | 2 6132003 89.99042 |
3. | 3 4222004 84.70363 |
4. | 4 10192005 71.01163 |
5. | 5 9042003 65.36345 |
+-------------------------------------+
How would I do that?
Thanks,
Debs
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/