标准化多个变量

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

Standardize multiple variables

问题

需要使用Stata标准化文本文件中的数百个变量,其中第一列是id,随后的列是varlist。转换后,需要将只包含id(第一列)和所有标准化值的新文件导出到我的目录。

英文:

I need to standardize hundreds of variables in a text file that has id as first column and varlist in subsequent columns using Stata. After conversion, I need to export the new file that only has id (first column) and all standardized values to my directory.

答案1

得分: 1

可能 

ds id, not

foreach v in r(varlist)' { tempvar work egen work' = std(v') drop v'
rename work' v'
}

查看 `help egen` 以确认其标准化方法是否与你的匹配
```

<details>
<summary>英文:</summary>

Possibly 

ds id, not

foreach v in r(varlist)&#39; {
tempvar work
egen
work' = std(v&#39;)
drop
v'
rename work&#39; v'
}


See `help egen` to check that its idea of standardization matches yours 




</details>



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

发表评论

匿名网友

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

确定