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: Convert Stock to panel of bilateral difference


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Convert Stock to panel of bilateral difference
Date   Fri, 15 Oct 2010 12:04:15 +0100

Also

bys year (country_name): g v2= cond(_n == 1, value, value-value[1]) 

Nick 
n.j.cox@durham.ac.uk 

Austin Nichols

Jonathan Stoeterau <jonathanstoeterau@gmail.com>:
For that case,

bys year (country_name): g v2=value-value[1] if _n>1
by year: replace v2=value if _n==1

Also read
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004

On Thu, Oct 14, 2010 at 11:37 PM, Jonathan Stoeterau
<jonathanstoeterau@gmail.com> wrote:

> I would like to convert country-specific stocks
> of a certain technology into a panel of bilateral
> differences. Specifically, my data currently has
> the following typical panel pattern:
>
> country_name    year    value
> Albania 1962    400
> Albania 1963    430
> Albania 1964    480
> ...
> Algeria 1962    3200
> Algeria 1963    3250
> Algeria 1964    3300
> ...
> Angola  1962 1200
> Angola  1963 1000
> Angola  1964 1300
>
> and i would like to generate a panel that looks like:
>
> country_name    year    country_name2 value
> Albania 1962  Albania  400    //the original value
> Albania 1962  Algeria  2800  //3200-400
> Albania 1962  Angola  800   //1200-400
> ...
> Albania 1963     Algeria  2820 //3250-430
> Albania 1962  Angola  570  //1000-430
> ...

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