Hello,
I would like to know how to generate a variable that sums all of each variable in the loop. For example,
I want to make a variable GPcost_year1 = GP_E7_C24 + GP_E8_C29 + GP_E9_C36 + GP_E10_C42
I used this code but it doesn't work.
Many thanks in advance.
Kim
I would like to know how to generate a variable that sums all of each variable in the loop. For example,
I want to make a variable GPcost_year1 = GP_E7_C24 + GP_E8_C29 + GP_E9_C36 + GP_E10_C42
I used this code but it doesn't work.
foreach x of varlist GP_E7_C24 GP_E8_C29 GP_E9_C36 GP_E10_C42 {
egen GPcost_year1 = total(`x')
}
egen GPcost_year1 = total(`x')
}
Kim
Comment