Hi all,
I please have another question.
So I have variables Revenue_GDP, Expenditure_GDP, Consumption_GDP, GovernmentConsumption_GDP, Investment_GDP, Exports_GDP Imports_GDP, Debt_GDP, Deficit_GDP
which are all as a % of GDP. I am trying to generate for example Revenue = Revenue_GDP * GDP_LCU to get Revenue figure and likewise for all the above variables.
I tried the following loop but it gives me error saying Revenue_GDP is already defined
The formula I am using:
local vars3 "Revenue Expenditure Consumption GovernmentConsumption Investment Exports Imports Debt Deficit"
local vars4 "Revenue_GDP Expenditure_GDP Consumption_GDP GovernmentConsumption_GDP Investment_GDP Exports_GDP Imports_GDP Debt_GDP Deficit_GDP"
foreach x of varlist `vars3' {
foreach s of varlist `vars4' {
gen `x' = `s' * GDP_LCU
}
}
Can you help me correct it. Thanks.
Related Posts with Foreach loop
Referring to a certain value when generating a new variableHello, I want to refer to a certain value when generating a new variable. My panel dataset looks a…
what should we do if after first differences the non-stationary of panel data still remained?hello everyone, I use a panel data and do after running the regression I get the residual and to fol…
Unlimited loop of events tested when using eventstudy2Hello! I am currently conducting my final thesis and for that I am using the package eventstudy2, a…
Request syntax assistance with v17 [table] command to get table of frequency in descending frequency orderI apologize for even asking, assuming there is something very simple I simply cannot find. As [tabl…
Rearranging individual dates within a varlistHi, I'm extremely new to Stata (5 weeks) and am stuck with something my lecturer has asked us to do.…
Subscribe to:
Post Comments (Atom)
0 Response to Foreach loop
Post a Comment