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

Re: st: use of expand

From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: use of expand
Date   Tue, 27 Apr 2004 11:23:55 +0100

At 10:28 27/04/04 +0100, Ann Fitzmaurice wrote:
Good morning

i have a data set with four variables, year ca age and n, where n is the number of each combination or the other three

yeat ca age n
1995 1 13 309
1995 1 14 420
1995 2 13 363

the years can range from 1995-2002, ca from 1-6 and age from 13-19

what i would like to do is to expand the data set that i have one line for each case so for the first line above i would have 309 duplicated lines

i have try using expand but it does not give me the data set i want (i know the total n when expanded)
As Nick Cox says, Ann doesn't specify exactly what is going wrong. However, I realise that -expand- can be confusing in that it puts the new observations at the end of the dataset, when the user usually wanted them to be next to the observations from which they were copied. Ann might like to try the -expgen- package, downloadable from SSC, which is a more user-friendly version of -expand-. In Stata, type

ssc desc expgen


findit expgen

to find out more.

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]

Opinions expressed are those of the author, not the institution.

* For searches and help try:

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