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
categorical outcome for first occuring eventDear stalisters, I am performing an event history analysis using a multinomial model (competing ris…
reshape data wide to long I am working on wide formatted data that have 11574 observations &11547 row. the repeated obser…
using loop for saving and directoryHello, I try to use the loop for my analysis and save them and draw charts. so I receive an error se…
Control for country effect in a pooled estimationHello everybody, I have panel data with two time periods (t=2) and n regions as entities. I am cons…
How can I learn to write Ado fileHello Sir, I want to write ado files to modify "tab" command so that I can get the desired output p…
Subscribe to:
Post Comments (Atom)
0 Response to Foreach loop
Post a Comment