Good morning
My problem is the following.
I would like to rename my variables using a loop.
My initial situation is this:
I have a set of variables with this name v1 v2 v3 .... v235
I would like to rename these variables for groups, but assigning each group of variables the same dates, from 2013 to 2019.
So as a final result I would like this:
REVENUES 2013
REVENUES 2014
REVENUES 2015
REVENUES 2016
REVENUES 2017
REVENUES 2018
REVENUES 2019
EBITDA 2013
EBITDA 2014
EBITDA2015
EBITDA 2016
EBITDA 2017
EBITDA2018
EBITDA2019
........
as code I had thought of using this:
local y = 2013
foreach v of var * {
rename (v1-v7) REVENUES`y '
rename (v8-v14) EBITDA`y '
.....
......
local ++ y
}
But unfortunately it doesn't work (I'm a newbie in Stata).
Thank you for any answers and help!
Related Posts with Rename Variables using a loop
can't install ivreg2/ivreg28/ivreg29/ivreg210Hello I tried to install ivreg2/ivreg28/ivreg29/ivreg210, but I am getting errors as follows for ea…
Dropping all the variables that are positioned after a variable.Hi, I would like to drop all the variables that are positioned after a given variable of my dataset…
ADF unit root testHello everyone. I am new on ADF unit root test and I want to ask something related to the ADF unit …
Panel data Fractional Response Models with a binary Endogenous explanatory variables and a binary instrumentHello, I am estimating the balanced panel data for the model where the dependent variable is a fract…
Reshaping long an usual datasetDear Statalist, I know how to reshape long a dataset when it has the appropriate format, but I'm fa…
Subscribe to:
Post Comments (Atom)
0 Response to Rename Variables using a loop
Post a Comment