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

Re: st: manipulating part of a variable name.


From   Ernest Berkhout <[email protected]>
To   [email protected]
Subject   Re: st: manipulating part of a variable name.
Date   Mon, 05 Apr 2004 15:49:52 +0200

At 15:16 5/04/2004, chris wallace wrote:
On Mon, 2004-04-05 at 14:13, Dev Vencappa wrote:

> local z "1986 1988 1990"
> foreach x of local z{
> gen XPRI3yr`x'=(XPRI`x'-XPRI`x'-2)
> }

You could try

foreach x of local z {
local y = `x'-2
gen XPRI3yr`x'=(XPRI`x'-XPRI`y')
}
which does the same as what Chris himself was searching for, namely

local z "1986 1988 1990"
foreach x of local z{
        gen XPRI3yr`x'=(XPRI`x' - XPRI`=`x'-2' )
 }

You have two substitutions here:
-the values starting with 1986 for `x' in the inside
- the function `=1986-2' on the outside




Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam

Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
http://www.seo.nl
===========================
A statistician: someone who insists
on being certain about uncertainty
===========================

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