admin管理员组文章数量:1536061
STATA学习笔记:函数
1. programming functions
(1)定义虚拟变量:inlist(z,a,b,…)
sysuse nlsw88.dta, clear
des2 industry
//【out】industry是类别变量
1 Ag/Forestry/Fisheries
Ag/Forestry/Fisheries是变量值"1"的标签
gen dummy = inlist(industry, 7,8,11)
//inlist(industry,7,8,11)中的industry是类别变量名
//7,8,11是以数字形式枚举
//如果industry变量值是7,8,11中的一个,新生成的虚拟变量值取1,否则取0
br industry dummy, nolabel
br industry dummy
2.string functions
(1)tostring
tostring converts variables in varlist from numeric to string.
webuse tostring, clear
(2)destring
destring year,replace
br
3.random_number functions
set obs 1000
//设置观察值个数
gen y_u = runiform()
gen y_n = rnormal()
gen y_p = poisson(6)
版权声明:本文标题:STATA学习笔记:函数 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726917495a1090295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论