Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: generating age variable


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: generating age variable
Date   Fri, 22 Nov 2002 19:56:45 -0000

Kim Price [HTML deleted!!!] 

> I would like to create an age variable that subtracts 
> each dob from a particular date. I looked at the 
> reference guides and web page, but they were not 
> helpful in answering this question. 
> I've tried the following, but they both create missing values. 

> 1) 
> generate age=mdy(4,15,01-dob)/365.25 

> and

> 2) 
> generate smpdate=mdy(4,1,01);

> format smpdate %d;

> gen age=(smpdate-dob)/365.25;

> Any suggestions will be greatly appreciated.

You need to tell us what -dob- is, e.g. 
by giving an example. 

Nick
n.j.cox@durham.ac.uk 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index