This seems to be a job for -stsplit-
Hope this helps,
Maarten
--- Hind Sbihi <[email protected]> wrote:
> 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/
>
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
*
* 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/