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: Use egen command with factor variables
From
Alfonso Sanchez-Penalver <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Use egen command with factor variables
Date
Thu, 28 Nov 2013 07:28:53 -0500
Hi Catharina,
My first impression is that you may have not defined the data as time series by using -tsset-. Have you?
Best,
Alfonso Sanchez-Penalver
> On Nov 28, 2013, at 2:52 AM, "Klepsch, Catharina" <[email protected]> wrote:
>
> Dear Stata Users,
>
> I was wondering whether it is possible to use the egen command with factor variables.
> For example, I tried to generate the mean value for a lagged variable and used:
>
> sort ID YEAR
> egen mean_x1 = mean(l.x1)
>
> Unfortunately, there occurs an error message which states:
> not sorted r(5)
>
> I'm not quite sure why this happens, because I sorted the data before. Even if I type:
> bys ID YEAR: egen mean_x1 = mean(l.x1)
>
> the same error message occurs.
>
> Any ideas how I can fix that? Please consider that it is not reasonable for my programming to first generate the lag/lead and then generate the mean.
>
> Thank's for any help.
> Catharina
>
>
>
>
>
> *
> * 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/