Hi,
I've got a very long code that runs a bunch of regressions and writes the output into CSV files. I want to include the number of observations for each category when I run a regression for example:
I've used e(N) to get the overall number of observations for the regression (n = 649):
However, the number of observations for each category currently come from just tabulating education which does not take into account the records eliminated due to missing data when running the regression. Hence the individual categories do not add up to 649.
I know I could do the following to get a table with the right numbers for the example above:
But in reality I have a long list of variables stored in local macros that are included in the regression and I don't want to have to unpack it and manually write an if statement for each one. Is there a way to do this? Please let me know if anything above isn't clear.
Thanks,
Nicole
I've got a very long code that runs a bunch of regressions and writes the output into CSV files. I want to include the number of observations for each category when I run a regression for example:
Model 1 | |||
Factor | n | Beta coefficient | |
Education level | n = 649 | test of trend: p = 0.10 | |
Less than Year 10 | 28 | Reference | |
Year 10 or Year 11 | 75 | 1.8 | |
Year 12 or equivalent | 177 | 2.5 | |
Trade/ Certificate | 389 | 2.8 | |
Bachelor degree | 247 | 3.3 | |
Postgraduate | 106 | 3.8 |
I've used e(N) to get the overall number of observations for the regression (n = 649):
Code:
regress age i.education local n = e(N)
I know I could do the following to get a table with the right numbers for the example above:
Code:
tab education if age != ., matcell(tabx)
Thanks,
Nicole
Comment