英文:
Tabulate a variable if label contains a specific word
问题
我有500个数据文件,每个文件有4000个变量。每个数据文件中的变量名称不一致。因此,我想制表显示包含单词“hospital”或“medical”的变量。
我正在使用Stata进行此操作。
英文:
I have 500 data files and each file has 4000 variables. The name of the variable isn't consistent across each data file. So I want to tabulate the variables that contain the word "hospital" or "medical" in them.
I am using Stata for this.
答案1
得分: 2
The commmand lookfor
will look through variable names and variable labels, and isn't case sensitive. Given this toy dataset
* -dataex- 生成的示例。要了解更多信息,请键入 help dataex
clear
input str1 Hospital float(x y)
""" 1 42
end
label var x ""Hospital size"
label var y ""Medical expenses"
here are some token results:
. lookfor hospital
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------------
Hospital str1 %9s
x float %9.0g Hospital size
. lookfor medical
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------------
y float %9.0g Medical expenses
See the help
for more details on lookfor
.
The official command ds
will allow searches of value labels, as will the community-contributed command findname
.
英文:
The commmand lookfor
will look through variable names and variable labels, and isn't case sensitive. Given this toy dataset
* Example generated by -dataex-. For more info, type help dataex
clear
input str1 Hospital float(x y)
"" 1 42
end
label var x "Hospital size"
label var y "Medical expenses"
here are some token results:
. lookfor hospital
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------------
Hospital str1 %9s
x float %9.0g Hospital size
. lookfor medical
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------------
y float %9.0g Medical expenses
See the help
for more details on lookfor
.
The official command ds
will allow searches of value labels, as will the community-contributed command findname
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论