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 at the end of May, 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 observations


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: add observations
Date   Mon, 6 Aug 2012 14:07:41 +0100

local N = _N + 1
expand 2
replace pd =4 in `N'/L


On Mon, Aug 6, 2012 at 1:25 PM, Ronnie Babigumira <rb.glists@gmail.com> wrote:
> Dear listers,
>
> I have a dataset that looks like this
>     hcod pd pdt
> 3092285 1 31
> 3092285 1 43
> 3092285 2 11
> 3092285 2 21
> 3092285 2 41
> 3092285 2 45
> 3092285 3 42
>
>
>
>
> I would like to add new observations so that I end up with
>     hcod pd pdt
> 3092285 1 31
> 3092285 1 43
> 3092285 2 11
> 3092285 2 21
> 3092285 2 41
> 3092285 2 45
> 3092285 3 42
> 3092285 4 31
> 3092285 4 43
> 3092285 4 11
> 3092285 4 21
> 3092285 4 41
> 3092285 4 45
>
> 3092285 4 42
>
>
>
> Basically, each unit (hcod) should have 4 periods (pd). What we would like to do is add all products (pdt) present in the non-missing periods to the missing period.
>
> Any suggestions to get us started would be very welcome.
>
*
*   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