Statalist


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

RE: st: RE: Panel data. Multiple variables generation.


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Panel data. Multiple variables generation.
Date   Fri, 18 Dec 2009 20:31:15 +0100

<>

*******
bysort i t:egen mytotal=total(Yijt)
*******

could be a smart solution. This would obviate lots of redundant storing of
variables. See Nick`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Laia Cirera i
Crivillé
Sent: Freitag, 18. Dezember 2009 20:27
To: Statalist
Subject: FW: st: RE: Panel data. Multiple variables generation.

I was afraid it wasn't send
 
.........................
 
> Martin, yes, I want a constant sum (egen=total()), but in the same
variables I will have different values for each exporting country (i) and
for each period of time (t).I am now creating variables manually for each
exporting country and period of time. But it's taking me a lot of time, as I
have data on 103 exporting countries for 9 periods of time. That means
generating 927 variables.This is what I am doing. As an example, for i=1 and
t=1:
>
> egen i1_1=total(Yijt) if i==1 & t==1
> ....
>
> till i=103: egen i103_1=total(Yijt) if i==103 & t==1
>
> And then, the same but for each period of time.
>
> I would like to know if there is a command which would generate me all
these variables (for each exporting country and period of time)
automatically.
>
> Thank you very much.
>
> Laia
> ----------------------------------------
>> From: martin.weiss1@gmx.de
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: RE: Panel data. Multiple variables generation.
>> Date: Fri, 18 Dec 2009 20:00:48 +0100
>>
>>
>> <>
>>
>> You want to look at the -sum()- function, but deeper answers require an
>> excerpt of your data. You can condition within the argument to the
function,
>> as seen here:
>>
>> *******
>>
>> clear*
>> set obs 10
>>
>> gen num=_n
>>
>> gen var=rnormal()<.5
>>
>> gen runningsum=sum(var)
>> gen runningsumodd=sum(var*mod(_n,2))
>>
>> list, noo ab(20)
>> *******
>>
>> If you want a constant sum, look at -egen, total()-...
>>
>> HTH
>> Martin
>>
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Laia Cirera i
>> Crivillé
>> Sent: Freitag, 18. Dezember 2009 19:50
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: Panel data. Multiple variables generation.
>>
>>
>> Good afternoon,
>>
>>
>> I am working with a panel data set, which contains data on bilateral
trade
>> flows for 103 countries and for 9 periods of time (t), where (i) are
>> exporting countries and (j) are importing countries .
>>
>> For each pair of trading countries (ij), and for each period of time (t),
I
>> have the variable Yijt. I need to create a new variable (Xit), which, for
>> each case where country (i) is exporting and for each period of time (t),
>> will add Yijt terms up. For example, if country i=1 and t=1 (X11), to
obtain
>> X11, I take each case of period t=1 where country 1 is exporting (i=1),
and
>> add all Yijt terms up. If country i=2 and and t=1 (X12), I take each case
of
>> period t=1 where country 2 is exporting (i=2), and add all Yijt terms up.
So
>> Xit will vary by exporting country(i) and period of time(t), but will be
the
>> same across bilateral pair of countries (ij) which have the same exporter
>> country (i) and period of time (t).
>>
>> Do you know which command I should use?
>>
>> Thanks a lot.
>>
>> Laia
>> _________________________________________________________________
>> ¡Ya está aquí Windows Live Spaces! Ahora podrás crear fácilmente tu
propio
>> sitio Web.
>> http://spaces.live.com/signup.aspx
>> *
>> * 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/
> _________________________________________________________________
> Busca desde cualquier página Web con una protección excepcional. Consigue
la Barra de herramientas de Windows Live hoy mismo y GRATUITAMENTE.
> http://www.toolbar.live.com 		 	   		  
_________________________________________________________________
Llama a tus amigos de PC a PC: ¡Es GRATIS!
http://get.live.com/messenger/overview
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index