Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: renaming variables
From
"Seed, Paul" <[email protected]>
To
"Seed, Paul" <[email protected]>, "[email protected]" <[email protected]>
Subject
st: RE: renaming variables
Date
Mon, 24 May 2010 15:13:42 +0100
And without the typos (for which apologies):
<snip>
clear
sysuse auto
forv i=40(1)107{
gen var`i'=1
}
//-rename2-
loc start 1990
forv i=53(3)107{
ren var`i' year`start'
loc ++start
}
clear
sysuse auto
forv i=40(1)109{
gen var`i'=1
}
//-rename3-
loc start 1990
forv i=53(3)107{
ren var`i' year`start'
local j = `i' + 1
ren var`j' thing_one_`start'
local j = `i' + 2
ren var`j' thing_two_`start'
loc ++start
}
(with acknowledgements to Dr Seuss)
http://en.wikipedia.org/wiki/The_Cat_in_the_Hat
*********************************************************************
Paul T Seed
King's College London, Division of Reproduction and Endocrinology
St Thomas' Hospital, Westminster Bridge Road, London SE1 7EH
*********************************************************************
*
* 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/