表格化一个变量,如果标签包含特定的词。

huangapple go评论51阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月7日 05:01:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75655814.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定