在 sas 数据集中重新排列变量 - 按字母顺序 [英] Rearranging variables in a sas dataset- alphabetical order
本文介绍了在 sas 数据集中重新排列变量 - 按字母顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 500 列数据集,我想按字母顺序重新排列所有变量.除了在 set 语句之前使用 retain 语句之外,我怎么能以其他方式做到这一点?
解决方案
可以动态生成变量名列表,使用PROC SQL
创建新的数据集.
I have like 500 columns of dataset, and I want to rearrange all the variables in an alphabetical order. How can I do that in any other way than using retain statement before set statement?
解决方案
You can generate the list of variable names dynamically, and create a new dataset using PROC SQL
.
proc sql ; select name into :VARLIST separated by ', ' from dictionary.columns where libname = 'SASHELP' and memname = 'CLASS' order by name ; quit ; proc sql ; create table ordered as select &VARLIST from sashelp.class ; quit ;
这篇关于在 sas 数据集中重新排列变量 - 按字母顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文