|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: xcollapse, multiple ifs
Thanks.
This suggestion does not work since what I am trying to do is make a table using
listtex ( user-written command by Roger Newson from SSC!) that looks like this
1960-1970 1970-1980
1980-1990
variable x mean x over 1960-1970 mean x over 1970-1980
mean x over 1980-1990
variable y mean y over 1960-1970 mean y over 1970-1980
mean y over 1980-1990
variable z ....
...
On Fri, Mar 27, 2009 at 10:47 AM, Nick Cox <[email protected]> wrote:
> -xcollapse- is a user-written command by Roger Newson from SSC or his
> own website. Please specify where user-written commands you refer to
> come from.
>
> The answer I think is No: at most one -if- condition. But what I guess
> you want is easily done otherwise, and -collapse- looks enough. For
> example,
>
> gen decade = floor(year/10)
>
> collapse x, by(decade)
>
> I assume that you don't really want to omit years like 1980. -ceil()-
> could be what you want instead of -floor()-.
>
> Nick
> [email protected]
>
> richard boylan
>
> Is there any way to have different "if statements" with the command
> xcollapse?
>
> I tried to do
>
> xcollapse (mean) m1 = x if year > 1970 & year <1980 (mean) m2 = x if
> year > 1980 & year < 1990...
>
> but I got an error message.
>
> One way to get around this problem is to just define new variables so
>
> x1 = x if year > 1970 & year < 1980
> x2 = x if year > 1980 & year < 1990
>
> and then
>
> xcollapse (mean) x1 x2...
>
> but was wondering if there was a better way of doing this.
>
> *
> * 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/