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

st: Accessing tempvars


From   Ed Blackburne <blackburne@shsu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Accessing tempvars
Date   Thu, 02 Sep 2004 11:12:18 -0500

I have a problem that has surely been answered in the past - I cannot, however, figure this out.

I want to access a temporary variable with a compound name.

The (obviuosly incorrect) code fragment is:


foreach __ids of global ReS_jv2 {
tempvar x`__ids'
quie gen ``x'`__ids''=0
}

I have also tried gen `x'`__iids'.


To more specific, I want to be able to generate temporary variables of, say, x1 x2 x3 x4, and be able to access them by name in my code.

The only combination of ` and ' and " that works in the gen statement is one that adds x1, x2, etc to the dataset - ie, not temporary.

Any pointers would be appreciated.


-Ed


Edward F. Blackburne
Associate Professor
Economics and International Business
Sam Houston State University

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index