Dear Statalist,
My question is how to rename variable names with matrix column names.
Currently, I am performing a sequence of regressions iteratively and aim to document the coefficients for each specification. To achieve this, I store the coefficients in a matrix and label the columns of the matrix with details about the corresponding specification. In my actual work, I have more than 400 iteration and have more than 30 independent variables. Here, I will simply to just 1 iteration and 4 independent variables to make my question easier to answer.
Here is the code I used to store coefficients:
My output matrix looks like :

Than I want to convert the matrix back to a data:
And the data looks like:

I want to rename 'colnames1' and 'colnames2' in the data with 'c1' and '12_0110' from the matrix. What is the approach I can take in my actual scenario where I need to rename over 400 column names?
Thank you very much.
My question is how to rename variable names with matrix column names.
Currently, I am performing a sequence of regressions iteratively and aim to document the coefficients for each specification. To achieve this, I store the coefficients in a matrix and label the columns of the matrix with details about the corresponding specification. In my actual work, I have more than 400 iteration and have more than 30 independent variables. Here, I will simply to just 1 iteration and 4 independent variables to make my question easier to answer.
Here is the code I used to store coefficients:
Code:
matrix coeff = J(5, 1, .) reg y x1 x2 x3 x4 if id == 12 & sample == "0110" matrix b = e(b) local id_time = string(12,"%02.0f") + "_" + "0110" matrix rownames b = `id_time' matrix coeff = coeff, b'
Than I want to convert the matrix back to a data:
Code:
svmat coeff, names(colnames) keep colname*
I want to rename 'colnames1' and 'colnames2' in the data with 'c1' and '12_0110' from the matrix. What is the approach I can take in my actual scenario where I need to rename over 400 column names?
Thank you very much.
Comment