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
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
RE: st: RE: generating year for a given age
Date
Tue, 4 May 2010 23:45:37 +0200
<>
Sorry, but what is the bottom line now? Reversed or not reversed?
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Debs Majumdar
Sent: Dienstag, 4. Mai 2010 23:43
To: [email protected]
Subject: Re: st: RE: generating year for a given age
My mistake. I just wrote down what the data manager told me. I should have
looked into the dataset before I answered Martin's question.
debs
----- Original Message ----
From: Martin Weiss <[email protected]>
To: [email protected]
Sent: Tue, May 4, 2010 2:29:37 PM
Subject: RE: st: RE: generating year for a given age
<>
" I don't think characters are reversed--see obs 4 in the original output:"
This observation prompted me to ask Debs, and he should know. I thought he
put the "1" in there erroneously, but I may be wrong. If so, Debs should say
so.
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Austin Nichols
Sent: Dienstag, 4. Mai 2010 23:26
To: [email protected]
Subject: Re: st: RE: generating year for a given age
Debs Majumdar <[email protected]> :
I don't think characters are reversed--see obs 4 in the original output:
clear all
inp byte id str13 dateint age_bl
1 "7242003" 81.00753
2 "6132003" 89.99042
3 "4222004" 84.70363
4 "10192005" 71.01163
5 "9042003" 65.36345
end
qui compress
qui destring, replace
g inty=dateint-1e4*floor(dateint/1e4)
g intm=floor(dateint/1e6)
g intd=floor(dateint/1e4)-intm*100
gen d=mdy(intm,intd,inty)
format d %tdMon_DD,_CCYY
gen birthday=d-age_bl*365
format birthday %td
gen yearwhenforty=yofd(birthday+40*365.25)
l
On Tue, May 4, 2010 at 5:18 PM, Debs Majumdar <[email protected]> wrote:
> 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/
*
* 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/