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: calculating differences in variables in Longitudinal Data
From
Abhimanyu Arora <[email protected]>
To
[email protected]
Subject
Re: st: calculating differences in variables in Longitudinal Data
Date
Tue, 10 Apr 2012 05:20:06 +0200
Hi
I see, perhaps xtset wold be better. Try this
egen panel_id=group(Company)
xtset panel_id year
forvalues i=1/54{
gen diff`i'=.
bys company:replace diff`i'=S2.var`i' if year==2011
}
Abhimanyu
On Tue, Apr 10, 2012 at 12:15 AM, Alexander Zoran Dozet <[email protected]> wrote:
> Great! Thank you for your the speddy help!
> However I run into some difficulties when some of the values are missing for some observations.
>
> I get the error message:
>
>
> "nothing found where name expected"
> r(198);
>
>
> Is there any way to handle that?
>
> Again, thank you!
>
> Best regards
> Alexander Dozet
>
>
>
>
> ----- Ursprungligt meddelande ----
> Från: Abhimanyu Arora <[email protected]>
> Till: [email protected]
> Kopia:
> Skickat: måndag, 9 april 2012 21:36
> Ämne: Re: st: calculating differences in variables in Longitudinal Data
>
> Hi
>
> I would do it as follows
>
> tsset year
> forvalues i=1/54{
> gen diff`i'=.
> bys company:replace diff`i'=S2.var`i' if year==2011
> }
>
> Cheers
> Abhimanyu
>
> On Mon, Apr 9, 2012 at 9:23 PM, Alexander Zoran Dozet <[email protected]> wrote:
>>
>> Dear Statausers,
>>
>> I have a small problem
>> that I suppose is easy to resolve if one knows the ansewer. Although it
>> probably is basic, I have tried to solve it by searching the internet
>> and hitting the books, I have not succeded in finding an answer.
>>
>> I have a dataset that looks like this:
>>
>>
>> Company Year Variable1 Variable2 Variable3.........Variable54
>>
>> Company1 2009 60 70 80
>> Company1 2010 65 72 81
>>
>> Company1 2011 67 71 85
>>
>> Company2 2009 85 80 70
>>
>> Company2 2010 75 85 78
>>
>> Company2 2011 77 88 76
>>
>> .
>> .
>> .
>> Company154
>>
>>
>> I hope the displayed data structure is kept in this e-mail.
>> Each company is occuring one time each year for each variable in the data
>> set (panel data). My variable Company is in string form. I have not
>> declared my dataset to be panel data. String is not allowed as an
>> identifier.
>>
>> I want to examine the difference between the
>> year 2010 and 2011 for each company and for each variable and to create a new variable for each of the differences for
>> example diffVar1, diffVar2,....
>>
>> I would be much grateful for any help!
>>
>> Best regards and cheers
>> Alexander Dozet
>>
>> *
>> * 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/
>
>
> *
> * 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/