Statalist


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

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


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Panel data. Multiple variables generation.
Date   Fri, 18 Dec 2009 20:19:05 +0100

<>

You can automate the production of the 927 variables with nested -forvalues-
loops very easily. See Nick`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0005


The question whether you want the (constant) value for these sums replicated
in all rows of your dataset, only you can answer... If you give an excerpt
of your data and the ultimate goal you have, I am pretty sure we can work
out something smarter...


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Laia Cirera i
Crivillé
Sent: Freitag, 18. Dezember 2009 20:11
To: Statalist
Subject: RE: st: RE: Panel data. Multiple variables generation.

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: [email protected]
> To: [email protected]
> 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: [email protected]
> [mailto:[email protected]] On Behalf Of Laia Cirera i
> Crivillé
> Sent: Freitag, 18. Dezember 2009 19:50
> To: [email protected]
> 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
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index