Statalist


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

Re: st: creating age variable for all ids


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: creating age variable for all ids
Date   Thu, 29 May 2008 15:51:14 +0100 (BST)

--- MAY BAYDOUN <mbaydoun2002@yahoo.com> wrote:
> I am trying to create a dataset in which I already
> have the id numbers but I would like to replicate them
> and add another variable age that has exactly the same
> values for all ids. So, the original file is:
> 
> id
> 1
> 2
> 3
> 4
> 5
> 
> The file I want to create is:
> 
> id   age
> 1    60 
> 1    65
> 1    70
> 1    75
> 1    80
> 2    60 
> 2    65
> 2    70
> 2    75
> 2    80
> ..
> 
> I was wondering if you can help find the easiest way
> to do that. Thanks a lot!

See -help expand-, -help by-, and the example below:

*--------------- begin example -------------
clear
input id
1
2
end

expand 5
sort id

by id: gen age = 55 + 5*_n
list
*---------------- end example --------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten


-----------------------------------------
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/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.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/



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