Hi Statalist.

I would like to create ratios of the value of different asset types for one group as a share of other groups. (Note these groups are categories within a nominal variable with 9 categories - 1-9). Each asset type is a continuous variable). The following is my attempt at coding the rules for four groups (reg1 - reg4):
Code:
local varlist totasset totfin totbank totcashi totequity totins totnonfin totprop totbus totveh
foreach i in local varlist {
gen reg1 = `i' if group == 3 / (`i' * inlist(group, 3, 4, 5)) // ratio of group3's assets as a share of groups 3, 4 & 5.
gen reg2 = `i' if group == 3 / (`i' * inlist(group, 3, 4)) // ratio of group3's assets as a share of groups 3 & 4.
gen reg3 = `i' if group == 3 / (`i' * inlist(group, 3, 5)) // ratio of group3's assets as a share of groups 3 & 5.
gen reg4 = `i' if group== 4 / (`i' * inlist(group, 4, 5)) // ratio of group4's assets as a share of groups 4 & 5.
}
I then want to feed this new list (reg1 - reg4) into a loop to create the same ratios for each of the asset types in my list.
Code:
local varlist totasset totfin totbank totcashi totequity totins totnonfin totprop totbus totveh
foreach i in local varlist {
foreach j in reg1 reg2 reg3 reg4 {
gen `i'_`j' = `i' if `j' }
}
I am hoping this will give me the asset values, e.g. of the first asset type:
totasset_reg1
totasset_reg2
totasset_reg3
totasset_reg4

I then plan to graph these ratios of asset values (separately) over age to see the change over the lifecycle.

Help is kindly appreciated.

Stata v.15.1. I am using panel data.