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

Re: st: index-scrolling varname


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: index-scrolling varname
Date   Tue, 05 Apr 2005 14:54:02 -0400

The answer here might depend in part on the actual structure of your variable names, but basically you want to deal with local macros. In general, see -whelp local- and/or the User's Guide on macros; and -help foreach-.

Specifically, something like:

foreach i in a b c {
egen sum_`i' = rsum(`i'_first `i'_second)
}


something like this would do it


At 08:01 PM 4/5/2005 +0200, you wrote:

I've to do a lot of computation on some groups of variables.
For simplicity, let's say I've to do rsum(a_first a_second) and, separetely,
rsum(b_first b_second)

I want to do it shorter using a loop:
- I generated a sort of index, let's say i, whose values is i="a" the first
turn, and i="b" at the second turn (and that's feasible)
- I would like to do something like:
egen i_tot=rsum(i_first i_second)

but I'm not able to explain to Stata that I'm interested in the value of i as a
part of the variable name.
Is it possible to do that?

--
Sara Pinoli
Ph.D. Student - Universit� Bocconi
Via Sarfatti 25 - 20136 Milano, Italy

Email: [email protected]





*
* 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/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601


*
* 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