Hello,
I'm trying to export some summary information from stata to excel using tabstat and putexcel and I need to subdivide the information according to specific categories. However, when I try to automatize the task I find a major problem when using tabstat: statistics for categories/labels with no values won't be displayed.
Let me give you an example. Suppose there is a categorical variable CAT with value labels 1 "A", 2 "B" and 3 "C"; but only C has observations (i.e. CAT has all three value labels but in the current dataset there are no observations for A and B). Therefore, when applying tabstat to get some statistics it would only display information for C. This is a problem for me because when automatizing the task there are some datasets that don't have values for some categories and I can't create a single code to export the statistics in a specific order. In my example, if I apply:
I would only get the scalar r(Stat1) containing the number of observations in C, but what I really need is a vector containing a statistic in the following order r(Stat1) for A, r(Stat2) for B and r(Stat3) for C. How can I make stata to display a scalar equal to "0" or "." even when there are no observations for A and B?
Thank you in advance.
I'm trying to export some summary information from stata to excel using tabstat and putexcel and I need to subdivide the information according to specific categories. However, when I try to automatize the task I find a major problem when using tabstat: statistics for categories/labels with no values won't be displayed.
Let me give you an example. Suppose there is a categorical variable CAT with value labels 1 "A", 2 "B" and 3 "C"; but only C has observations (i.e. CAT has all three value labels but in the current dataset there are no observations for A and B). Therefore, when applying tabstat to get some statistics it would only display information for C. This is a problem for me because when automatizing the task there are some datasets that don't have values for some categories and I can't create a single code to export the statistics in a specific order. In my example, if I apply:
Code:
tabstat CAT, by(CAT) statistic(count) save
Thank you in advance.
Comment