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

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

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

  1. * -dataex- 生成的示例。要了解更多信息,请键入 help dataex
  2. clear
  3. input str1 Hospital float(x y)
  4. """ 1 42
  5. end
  6. label var x ""Hospital size"
  7. label var y ""Medical expenses"

here are some token results:

  1. . lookfor hospital
  2. Variable Storage Display Value
  3. name type format label Variable label
  4. -----------------------------------------------------------------------------------------------------
  5. Hospital str1 %9s
  6. x float %9.0g Hospital size
  7. . lookfor medical
  8. Variable Storage Display Value
  9. name type format label Variable label
  10. -----------------------------------------------------------------------------------------------------
  11. 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

  1. * Example generated by -dataex-. For more info, type help dataex
  2. clear
  3. input str1 Hospital float(x y)
  4. "" 1 42
  5. end
  6. label var x "Hospital size"
  7. label var y "Medical expenses"

here are some token results:

  1. . lookfor hospital
  2. Variable Storage Display Value
  3. name type format label Variable label
  4. -----------------------------------------------------------------------------------------------------
  5. Hospital str1 %9s
  6. x float %9.0g Hospital size
  7. . lookfor medical
  8. Variable Storage Display Value
  9. name type format label Variable label
  10. -----------------------------------------------------------------------------------------------------
  11. 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:

确定