Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: collapse _all by


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: collapse _all by
Date   Mon, 23 Sep 2002 08:49:51 +0000

Fred Wolfe  wrote
> At 05:50 PM 9/22/2002 -0700, you wrote:
> >I want to collapse a large number of variables by tract, i.e.
> >
> >. collapse (sum) _all, by(tract)
> >
> >Naturally, stata complains that tract is included in _all:
> >
> >tract may not be both target and by()
> >r(198);
> >
> >Any clever way around that?
>
> Check out -order- to move tract to the front. The collapse var2-varlast,
> by(tract(.

Another way is

.. unab all: _all
.. local allx: subinstr local all "touse" " ", all 
.. collapse (sum) `allx', by(tract)

regards
uli


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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