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]

st: Re: st: Σχετ: st: diving values of a column with other values of the same column


From   Nick Cox <[email protected]>
To   [email protected]
Subject   st: Re: st: Σχετ: st: diving values of a column with other values of the same column
Date   Wed, 6 Feb 2013 00:17:11 +0000

I think you have to tell us the rule your data follow. Otherwise the
reply to "my data are more complicated than that" is just "so your
code needs to be more complicated than that".

For a general discussion, see the Speaking Stata column in Stata
Journal 11(2) from 2011:

http://www.stata-journal.com/article.html?article=dm0055

Nick

On Wed, Feb 6, 2013 at 12:07 AM, Tzaloupas Dimitrov
<[email protected]> wrote:

> thank you very much  scott.  The only problem is that my real panel is unbalanced. So it is not always 3 obs/ 3 obs
>
> Is there a way to modify your code so as to take into account this unbalanced panel data set?

Scott Merryman <[email protected]>

On Tue, Feb 5, 2013 at 3:34 PM, Tzaloupas Dimitrov

>> I have the following excel file which I import into Stata
>>  Country          overall         specific            dates                              values
>> DD                         gg           0             01/11/2001                               5
>> DD                         gg           0             01/12/2001                               2
>> DD                         gg           0             01/01/2001                               3
>>  DD                        gg           zz           01/11/2001                               15
>> DD                         gg           zz           01/12/2001                               12
>> DD                         gg           zz           01/01/2001                              13
>> EE                          gg           0             01/11/2001                               0.5
>> EE                          gg           0             01/12/2001                               0.2
>> EE                          gg           0             01/01/2001                               0.3
>> EE                          gg           zz           01/11/2001                               25
>> EE                          gg           zz           01/12/2001                               122
>> EE                          gg           zz           01/01/2001                              2 3
>>
>> For each country  separately(DD and EE) I would like to   divide the values that correspond to specific==zz by the values that correspond to speciffic==0
>>
>> For example, for DD I want to divide the vector  of values (15 12 13) that corresponds to specific==zz by the vector (5 2 3) that corresponds to specific==0; so as to construct a new vector of values=(15/5 12/2 13/3)
>
>
> bys country (spec dates) : gen values2 = values/values[_n-3]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index