如何读取 SAS 数据集中的变量名? [英] How to read variable names in a SAS data set?
问题描述
是否有任何语句函数能够获取变量的名称?最好将它们放入另一个数据集的列、文本字段或宏变量中.
Are there any statementsfunctions capable of get the name of variables? Preferrably putting them into a column of another data set, a text field or a macro variable.
例如
- 数据集 1
Name age sex
Jk 14 F
FH 34 M
预期数据集
Expected data set
Var_name_of_dataset1
Name age sex
PS:我知道一个语句:select into,它做某事相关它可以将列的值读入带有自定义分隔符的字段,因此希望有类似的方法将列名读入字段或列.
PS: I know a statement: select into, which does sth relevantly It can read the value of a column into a field with customized separetors, and therefore wish there are similar ways of reading column names into a field or a column.
谢谢
推荐答案
PROC CONTENTS 将是在数据集中获取该信息的最快方法.列名可以在 NAME 列中找到.
PROC CONTENTS would be the quickest way to get that information in a dataset. Column names can be found in the column NAME.
proc contents data=sashelp.class out=contents noprint; run;
这篇关于如何读取 SAS 数据集中的变量名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!