I have been trying to retrieve the coefficients and p-values (or t-statistics if that is easier) from (reg empratio year if naics == `i') and put them all into a table along with their corresponding NAICS codes. The macro `i' above indicates which data is included in each regression. So for each NAICS code there would be one row that contains information from the regression of empratio (ratio of California to non-California employment for the given NAICS designation) on the year of the observation. I am hoping for the table to have the following format:
naics | Beta (from reg empratio year if naics == `i') | p-value |
311111 | .0010051 | 0.766 |
311119 | .0003909 | 0.055 |
311212 | 0.0084305 | 0.005 |
... | ... | ... |
It would include ~252 rows, each uniquely corresponding to a NAICS code (value of naics), with each NAICS code being followed in the row by the result of the year coefficient when empratio is regressed on year. I would also like to be able to save it as an excel file or a new .dta file.
Here is some sample data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(naics year empratio) 311111 2000 .1054219 311111 2001 .09380454 311111 2002 .09960062 311111 2003 .10409006 311119 2000 .06462295 311119 2001 .06923293 311119 2002 .07656486 311119 2003 .08883994 311212 2000 .4896099 311212 2001 .3780575 311212 2002 .3419106 311212 2003 .385101 311225 2000 .13741311 311225 2001 .12030268 311225 2002 .13152106 311225 2003 .1190995 311340 2000 .10173257 311340 2001 .10152242 311340 2002 .10921299 311340 2003 .13685288 end
Code:
levelsof naics, local(lvls) foreach i in `lvls' { reg empratio year if naics == `i' }
0 Response to Creating table with many simple linear regression (regress) outputs
Post a Comment