Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: expanding dataset by n observations where n varies


From   Hind Sbihi <[email protected]>
To   [email protected]
Subject   st: expanding dataset by n observations where n varies
Date   Thu, 13 Sep 2007 16:09:41 -0700 (PDT)

Dear all,

I am new to this listserve and hope someone will find this question interesting.

The dataset I am working with comprises repeated observations for several thousands subjects. Each observation consists of a job/exposure level/hearing test combination. The data is long shaped.
I am trying to truncate these units of observation by year.
For example the following subject has only one job and 8 hearing tests over 47 years (data on exposure not shown).

       +-----------------------------------------------------+
       | studyno1    startdat     enddate       testd       time |
       
         1100214   01 Aug 42   31 Dec 89   15 Feb 78      1 |
         1100214   01 Aug 42   31 Dec 89   15 Oct 79      2 |
         1100214   01 Aug 42   31 Dec 89   15 Oct 80      3 |
         1100214   01 Aug 42   31 Dec 89   15 Oct 81      4 |
         1100214   01 Aug 42   31 Dec 89   15 Dec 82      5 |
         1100214   01 Aug 42   31 Dec 89   15 Dec 83      6 |
         1100214   01 Aug 42   31 Dec 89   15 Mar 85      8 |
         1100214   01 Aug 42   31 Dec 89   15 Mar 87     10 |
    
My main objective is to expand these observations and obtain something like this output

       studyno1    startdat     enddate       testd           time   
         1100214   01 Aug 42   31 Dec 43   .                  .
         1100214   01 Jan 43   31 Dec 44    .                  .
           .
           .
           .
         1100214   01 Jan 50   31 Dec 50   .                   .
         1100214   01 Jan 51   31 Dec 52   .                   .
         .
         .
         1100214   01 Jan 89   31 Dec 89   15 Mar 87    10
****************************************************

I have tried expand command but it is not flexible enough since every subject has a different number of observations.
I created a variable to count the number of observations that need to be expanded (by rounding the ratio of job duration over 365.25 days), however expandby gave strange results.

Any help would be very welcome
I would be grateful if you would let me know how to deal with this problem.

Thank you

Kind regards

Hind Sbihi

School of Occupational and Environmental Health
University of British Columbia

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index