Hi all,
I have 55 datasets, all with the same set of 60 variables, but some of them have missing data for some of the variables. I have a created a set of matrices that relate to each variable when it doesn't have missing data. I would like to put these matrices into an Excel sheet using code something like the code below. If h_urban has missing data, and no matrix is created, how can I make my foreach loop recognise that there are now only 3 variables in y1, and put only those names in F1, G1 and H1 and only those values in F2, G2 and H2?
Thanks,
Sonia
I have 55 datasets, all with the same set of 60 variables, but some of them have missing data for some of the variables. I have a created a set of matrices that relate to each variable when it doesn't have missing data. I would like to put these matrices into an Excel sheet using code something like the code below. If h_urban has missing data, and no matrix is created, how can I make my foreach loop recognise that there are now only 3 variables in y1, and put only those names in F1, G1 and H1 and only those values in F2, G2 and H2?
Code:
local y1 = "h_region h_wealth h_urban m_edu" findname, all(!missing(@)) local(y1_nonmissing) foreach cell1 in F G H I { local i1 = `i1' + 1 local mat1 : word `i1' of `y1_nonmissing' di "`cell1'" di "`mat1'" putexcel `cell1'1 ="`mat1'", bold putexcel `cell1'2 =matrix(`mat1') }
Sonia
Comment