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
Equation notation logistic regressionDear colleagues, For my thesis, I would like to write an equation showing the final Model for a bino…
Moderation in ordered regressionHello! For my thesis, I have to do some regressions in STATA. I am not very good with STATA at the …
Table CreationHii, I have a hospitals data. There is variable named districts, blocks and hospital_name, there are…
Shorten variable labels using foreachHello I am trying to shorten the labels of the variable in my dataset. Eg: storage display value …
Custome made program that loads dataset and keeps variables give "nor variables defined" errorSo I want to make a program that loads a dataset, and optinally keep some variables. I am unable to …
Subscribe to:
Post Comments (Atom)
0 Response to Foreach loop
Post a Comment