Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Panel Data Manipulation, divide all by a group of data??


From   Duha Altindag <[email protected]>
To   [email protected]
Subject   Re: st: Panel Data Manipulation, divide all by a group of data??
Date   Fri, 9 Jul 2010 16:42:07 -0500

I suppose your countries are also associated some time variable, since
this is a panel. Then you can do the following:


forval c=1/2 {
g col`c'_aboveUSA=.
forval t=1/3 {
qui su column`c' if country=="USA" & time==`t'
replace col`c'_aboveUSA= column`c'>=r(mean) & time==`t'
}
}

I guess this will work if you have a balanced panel, though.



On Fri, Jul 9, 2010 at 3:58 PM, Halit Akturk <[email protected]> wrote:
> Hi,
> I am a Stata 11 user. I am trying to do some data manipulation with a
> panel data (long form). Can someone advice me on how to do what I am
> trying to do in a more efficient way? I have a panel data of the
> following sort:
>           column1         column2
> CAN     10                     1
> CAN     55                     2
> CAN     12                     3
> UK       11                     4
> UK       12                     5
> UK       9                       6
> USA     16                     7
> USA     22                     8
> USA     25                     9
>
> What I want to is to divide all values in column 1 and column 2 for
> all countries by only the USA values in column 1!
> I did this computation in sort of a manual way by basically getting
> rid off all wariables other than USA column 1 values and saved that as
> a .dta file (say try.dta). Then I merged try.dta with the existing
> .dta file I have (above). This produced me a new column (say column 3)
> which contains USA column 1 values aligned with CAN and UK and USA
> column 1 values. Then I was able to compute by simply manipulating
> columns. My method is sort of manual and this requires me to have a
> seperate .dta file which I really don't like.
> Anyhow, I hope I am clear in explaining what I like to do. I want to
> learn whether there is an easier way of doing what I am trying to do
> in a more efficient and nicer way.
>
> Thank you all for your help.
>
> Halit Akturk
> Department of Economics
> Vanderbilt University
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index