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: Σχετ: st: Re: st: Σχετ: st: Σχετ: st: Re: st: Σχετ: st: diving values of a column with other values of the same column
From
Tzaloupas Dimitrov <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Σχετ: st: Re: st: Σχετ: st: Σχετ: st: Re: st: Σχετ: st: diving values of a column with other values of the same column
Date
Wed, 6 Feb 2013 00:59:56 +0000 (GMT)
Well done Nick!It works!!!!!!
I want to ask something else
Having applied your code, my matrix becomes
Country overall specific dates values new variable
DD gg 0 01/11/2001 5 x1
DD gg zz 01/11/2001 15 x1
DD gg 0 01/12/2001 2 x2
DD gg zz 01/12/2001 15 x2
DD gg 0 01/01/2002 3 x3
DD gg zz 01/11/2002 15 x3
EE gg 0 01/11/2001 0.5 x3
EE gg zz 01/11/2001 25 x3
EE gg 0 01/12/2001 0.2 x3
EE gg zz 01/12/2001 122 x3
I want to plot this new variable for each country using xtline but now my matrix in not in a very nice order
Is there a way to plot this new variable over time for each country?
Many thanks NIck
----- Αρχικό μήνυμα -----
Απο: Nick Cox <[email protected]>
Προς: [email protected]
Κοιν.:
Στάλθηκε: 12:44 π.μ. Τετάρτη, 6 Φεβρουαρίου 2013
Θέμα: st: Re: st: Σχετ: st: Σχετ: st: Re: st: Σχετ: st: diving values of a column with other values of the same column
Please try my code. If it doesn't work with your data, try to think
out why not.
Then please read my paper.
If it's not accessible to you, then this paper will be
SJ-2-1 pr0004 . . . . . . . . . . Speaking Stata: How to move step by: step
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q1/02 SJ 2(1):86--102 (no commands)
explains the use of the by varlist : construct to tackle
a variety of problems with group structure, ranging from
simple calculations for each of several groups to more
advanced manipulations that use the built-in _n and _N
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004
By the way, the official Harvard archives show that Statalist
archiving software just can't cope with Greek characters: see
http://hsphsun3.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1302/Author/article-127.html
If you can find a way to suppress the Greek characters, your posts
will be easier to read for most Statalist members.
Nick
On Wed, Feb 6, 2013 at 12:34 AM, Tzaloupas Dimitrov
<[email protected]> wrote:
> Nick, I just saw your new reply
>
>
> Here is the information on the variables
> country : str2
> overall str13
> specific str3
>
>
>
>
> ----- Αρχικό μήνυμα -----
> Απο: Tzaloupas Dimitrov <[email protected]>
> Προς: "[email protected]" <[email protected]>
> Κοιν.:
> Στάλθηκε: 12:30 π.μ. Τετάρτη, 6 Φεβρουαρίου 2013
> Θέμα: st: Σχετ: st: Re: st: Σχετ: st: diving values of a column with other values of the same column
>
> thanks Nick.
>
> The data set is unbalanced. I rewrite the example
>
> 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 zz 01/11/2001 25
> EE gg zz 01/12/2001 122
>
>
> So we have 6 obs for DD and 4 for EE
>
> I have created identifiers. So, I have
>
> identif Country overall specific dates values
> 1 DD gg 0 01/11/2001 5
> 1 DD gg 0 01/12/2001 2
> 1 DD gg 0 01/01/2001 3
> 2 DD gg zz 01/11/2001 15
> 2 DD gg zz 01/12/2001 12
> 2 DD gg zz 01/01/2001 13
> 3 EE gg 0 01/11/2001 0.5
> 3 EE gg 0 01/12/2001 0.2
> 4 EE gg zz 01/11/2001 25
> 4 EE gg zz 01/12/2001 122
>
>
> I do not thing that there a specific pattern in the data. Across countries the time series obs vary
>
> Does this help?
>
> Thanks
>
>
>
> ----- Αρχικό μήνυμα -----
> Απο: Nick Cox <[email protected]>
> Προς: [email protected]
> Κοιν.:
> Στάλθηκε: 12:17 π.μ. Τετάρτη, 6 Φεβρουαρίου 2013
> Θέμα: st: Re: st: Σχετ: st: diving values of a column with other values of the same column
>
> 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/
*
* 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/