Dear Salah,
Thank you so much for your suggestion. I will try it
out.
Best,
May
--- Salah Mahmud <[email protected]> wrote:
> Hi May,
> I do not have Stata to test the following solution
> it may need some tweaking:
>
> sort id age
> by id: gen total_duration =age[_N] - age[1]
> by id: gen average_freq=total_duration /_N
>
> hope this helps,
>
> salah mahmud
>
>
>
>
>
> On Tue, Jun 10, 2008 at 12:45 PM, MAY BAYDOUN
> <[email protected]> wrote:
> > Dear statalisters,
> >
> > I was wondering if you could help me figure out a
> way
> > to obtain the frequency at which each individual
> was
> > examined (i.e. average number of follow-up visits
> per
> > year) and the total duration (i.e. time between
> first
> > and last visit) if the dataset is person-period
> format
> > and I have the following structure:
> >
> > id visit age at visit
> > 1 1 30
> > 1 2 32
> > 1 3 36
> > 1 4 50
> > 2 1 45
> > 2 2 46
> > 3 3 50
> > 3 4 56
> > 3 5 60
> > 3 6 65
> > 4 1 42
> > 4 2 48
> >
> > In other words, the distance in age between visits
> > varies for each individual, the number of visits
> is
> > not the same and the age at baseline varies as
> well.
> >
> > So, I would like to obtain the following variables
> > (made up numbers for frequencies):
> >
> > id Freq Duration
> > 1 0.5 20
> > 2 0.4 1
> > 3 0.3 15
> > 4 0.6 6
> >
> > The duration for individual 1 for example is:
> > 50-30
> >
> > The average frequency is the tricky one I guess,
> it is
> > for individual 1:
> > [1/(32-30) + 1/(36-32) + 1/(50-36)]/4
> >
> > Thanks a lot and hope to hear from you soon,
> >
> > Sincerely yours,
> >
> > May
> >
> >
> > May Baydoun, PhD in Epidemiology (UNC-Chapel Hill)
> > Staff Scientist,
> > National Institute on Aging, NIH/IRP, Biomedical
> > Research Center,
> > Baltimore, MD
> >
> >
> >
> >
> > May Baydoun, PhD in Epidemiology (UNC-Chapel Hill)
> Staff Scientist, National Institute on Aging,
> NIH/IRP, Biomedical Research Center, Baltimore, MD
> >
> >
> >
> > *
> > * 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/
> >
> *
> * 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/
>
May Baydoun, PhD in Epidemiology (UNC-Chapel Hill) Staff Scientist, National Institute on Aging, NIH/IRP, Biomedical Research Center, Baltimore, MD
*
* 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/