Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Add new observations.


From   André Gyllenram <a_gyllenram@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Add new observations.
Date   Mon, 24 Sep 2012 12:49:22 +0200

Thank you Nick! That worked!

/André Gyllenram

----------------------------------------
> Date: Mon, 24 Sep 2012 11:25:24 +0100
> Subject: Re: st: Add new observations.
> From: njcoxstata@gmail.com
> To: statalist@hsphsun2.harvard.edu
>
> This sounds like a case for -fillin-. See the help and
>
> SJ-5-1 dm0011 . . . . . . . . . . . . . . Stata tip 17: Filling in the gaps
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
> Q1/05 SJ 5(1):135--136 (no commands)
> tips for using fillin to fill in gaps in a rectangular
> data structure
>
>
> Nick
>
> On Mon, Sep 24, 2012 at 11:13 AM, André Gyllenram
> <a_gyllenram@hotmail.com> wrote:
>
> > I have information on all stocks that a number of individuals owns in a given time-period. A small part of the data looks like this:
> >
> >
> > Individual date stock portfolioweight
> > 3 2000 1 .1
> > 3 2000 4 .2
> > 3 2000 9 .3
> > 3 2000 10 .4
> > 4 2000 1 .1
> > 4 2000 2 .1
> > 4 2000 3 .1
> > 4 2000 4 .2
> > 4 2000 5 .1
> > 4 2000 6 .1
> > 4 2000 7 .1
> > 4 2000 8 .2
> > 5 2000 3 1
> >
> >
> >
> >
> >
> > From the data above I have created a list of all stocks that is owned by at least one individual. In this example the individuals together owns ten different stocks.
> >
> > Stock date
> > 1 2000
> > 2 2000
> > 3 2000
> > 4 2000
> > 5 2000
> > 6 2000
> > 7 2000
> > 8 2000
> > 9 2000
> > 10 2000
> >
> > What i want to do is that I for every individual and date would like to add the stocks that the individual do not own. Individual 3 above owns 4 stocks but I want to add 6 new rows for the stocks he does not own. I want to do the same for all other individuals. This means that I need 10 rows for every individual. I want the data to look like this:
> >
> >
> >
> >
> > Individual date stock portfolioweight
> > 3 2000 1 .1
> > 3 2000 2 .
> > 3 2000 3 .
> > 3 2000 4 .4
> > 3 2000 5 .
> > 3 2000 6 .
> > 3 2000 7 .
> > 3 2000 8 .
> > 3 2000 9 .3
> > 3 2000 10 .4
> >
> >
> > 4 2000 1 .1
> > 4 2000 2 .1
> > 4 2000 3 .1
> > 4 2000 4 .2
> > 4 2000 5 .1
> > 4 2000 6 .1
> > 4 2000 7 .1
> > 4 2000 8 .2
> > 4 2000 9 .
> > 4 2000 10 .
> >
> > 5 2000 1 .
> > 5 2000 2 .
> > 5 2000 3 1
> > 5 2000 4 .
> > 5 2000 5 .
> > 5 2000 6 .
> > 5 2000 7 .
> > 5 2000 8 .
> > 5 2000 9 .
> > 5 2000 10 .
> >
> >
> > The variable portfolioweight is missing if the individual does not own the particular stock.
> >
> >
> >
> > I have tried to use merge and joinby but it does not seem to be the right way to do this. Or am I missing something?
> >
> >
> >
> > All help is appreciated.
> >
> >
> > Kind regards
> > André Gyllenram
> >
> >
> > *
> > * For searches and help try:
> > * http://www.stata.com/help.cgi?search
> > * http://www.stata.com/support/statalist/faq
> > * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index