Peu*_*tch 1 variables label stata
我正在使用 do 文件生成多个变量的图表,我希望能够检索变量标签(以便我可以将其用作图表标题)。
在我的梦里,有类似这样的事情:
sysuse auto, replace
local pricelabel = varlab(price)
display "Label for price variable is `pricelabel'"
Run Code Online (Sandbox Code Playgroud)
这将(在我的梦想中)产生:
Label for price variable is Price
Run Code Online (Sandbox Code Playgroud)
我查看了描述、总结以及标签部分的文档,但似乎找不到解决方案。
有关本地/全局宏的扩展功能,请参阅帮助文件:(help extended_fcn其中extended_function是variable label varname[您要求的内容]或value label varname[不是您要求的内容,但可能有用])。例如:
sysuse auto, clear
local x : variable label foreign
local y : value label foreign
di "`x'"
di "`y'"
Run Code Online (Sandbox Code Playgroud)
回报
. sysuse auto, clear
(1978 Automobile Data)
. local x : variable label foreign
. local y : value label foreign
. di "`x'"
Car type
. di "`y'"
origin
Run Code Online (Sandbox Code Playgroud)