我的公司级数据集中有两个变量,包含行业分类和该公司所属的行业名称。对于给定的id_class,数据中可能缺少industry_name。见下文
| id_class | industry_name |
|----------|-------------------|
| 10 | auto |
| 11 | telecommunication |
| 12 | . |
我使用levelsof
命令按行业进行回归,将id_class中的每个类别保存到本地宏,以允许我遍历每个类别
levelsof id_class, (id_class_list)
foreach i of local id_class_list {
reg y x if id_class == `i'
}
我想将每个回归的估计系数保存到表中(我知道如何执行此部分),但我希望表的标题包含在industry_name
变量中。我怎么能这样做?
答案 0 :(得分:1)
您可以使用宏扩展函数来提取数据属性,例如变量值标签,如下所示:
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'
}
答案 1 :(得分:0)
查看statsby
:查看其帮助和手动输入