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
Merge One Variable to Multiple Instances in Master DatasetHello, I have a dataset in which multiple organizations can serve the same county. I have a crosswa…
Generating dummy variables based on variables with multiple categoriesHi, I have a (panel) dataset that contains the following variables for each observation: person_id …
Interaction Term and Measuring the Impact of Pre- and Post-ReformDear Members, I have panel data, spanning between 2005 to 2015. I just want to measure the impact o…
Constraints with fmmI have a pretty basic mixture regression thus: . fmm 2: regress y x1 x2, lcprob(x1) What I would l…
Weighted median and range with svy dataHi all, I'm hoping this is an easy response but I can't seem to find an answer to it. I'm working w…
Subscribe to:
Post Comments (Atom)
0 Response to Foreach loop
Post a Comment