Statalist The Stata Listserver


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

RE: st: generate observations by group/levels- aplologies if this message appears more than once -


From   "Rajesh Tharyan" <R.Tharyan@exeter.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: generate observations by group/levels- aplologies if this message appears more than once -
Date   Sun, 20 May 2007 16:19:54 +0100

Hi,

Many thanks for this..

I did try expand but after that I tried replace year[_n+1]=year+1 and of
course I got the weights not allowed error

Did not occur to me to use the _n.

Many thanks
rajesh 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jeph Herrin
Sent: 20 May 2007 16:01
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: generate observations by group/levels- aplologies if this
message appears more than once -

To increase the number of records by 2 years, -expand- by 3:

  expand 3
  bysort Co year : replace year=year+_n-1


hth,
Jeph


Rajesh Tharyan wrote:
> Hi all,
> 
> 
> I am trying the do the following. If I have a data set which looks like
this
> 
> Co    year
> A      1986
> A      1999
> B      1987
> 
> I want to say increase the observations for each company year by any
number
> of years I specify. Lets assume expanding by two years.
> 
> So the resulting dataset will look like
> 
> Co year
> 
> A 1986
> A 1987
> A 1988
> A 1999
> A 2000
> A 2001
> B 1987
> B 1988
> B 1989
> 
> I cant set obs or expand by a grouping variable.  I was then trying to
split
> each file into several files first based on levels of co and then levels
of
> year, then expand , fillinin missing values etc. But that route is making
> the process unnecessarily complicated (I think)
> 
> Is there a more staright forward way to do this
> 
> Any help is valuable
> 
> Thanks
> rajesh
> 
> 
> 
> *
> *   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/

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