I am new to Stata and would really appreciate your help!
I am trying to export my result to an excel file using putexcel. I struggle to come up with a solution to put the value label of a categorical variable into my excel instead of the value name.
So instead of "2vs1bn.Sentiment1" I would like to see the label: "mixed vs base"
//Compare Sentiment
regress changelikes_percentage i.Sentiment1
pwcompare i.Sentiment1, effects
matrix A = r(table_vs)
matrix B = A[1,1..6]'
matrix list B
matrix C = A[4,1..6]'
matrix list C
putexcel A1 = "Sentiment", bold
putexcel A2 = matrix(B), names nformat(number_d4)
putexcel C3 = matrix(C), nformat(number_d2)
putexcel B2 = "Coefficient", bold hcenter
putexcel C2 = "p-Value", bold hcenter
//Formatting Excel
putexcel (A2:C2), border("bottom")
putexcel (A2:A10), border("right")
I would also really appreciate any help on my code to make it less ponderous.
Thank you!
0 Response to Exporting Results to Excel: value labels instead of names, categorical variable
Post a Comment