0
votes

I have two variables in my firm-level dataset containing the industrial classification and the industry name to which that company belongs. For a given id_class, industry_name might be missing in the data. See below

| id_class | industry_name     |
|----------|-------------------|
| 10       | auto              |
| 11       | telecommunication |
| 12       | .                 |

I'm doing regressions by industry using the levelsof command to save each category in id_class to a local macro to allow me to loop through each category

levelsof id_class, (id_class_list)

foreach i of local id_class_list {

    reg y x if id_class == `i'

}

I want to save the estimated coefficients for each regression to a table (I know how to do this part), but I want the table to have the title contained in the industry_name variable. How can I do this?

2

2 Answers

1
votes

You can use the macro extended functions for extracting data attributes, such as variable value labels, like this:

sysuse auto
levelsof foreign, local(list)
foreach v of local list {
    local vl: label (foreign) `v'
    di "Car Origin is `vl':"
    reg price if foreign==`v'
}
0
votes

have a look at statsby : check out its help and manual entry