在SAS IML中提取列名称

时间:2013-09-10 17:04:43

标签: sas

我希望使用IML编写一个宏,它能够提取数据集的列名,以便稍后用作名称。

一些伪代码:

    proc iml;
        read all dataset into matrix_a [colname = varnames];
        (...)
        names = varnames;
        create new_data_set [rownames = names];
    quit;

这可能吗?

1 个答案:

答案 0 :(得分:1)

当然可以。

data test;
array x[10];
do i=1 to 10;
    do j=1 to 10;
        x[j] = (i-1)*10 + j;
    end;
    output;
end;
drop i j;
run;

proc iml;
use test;
read all var _num_ into test[colname=names];
close test;

test = test`;
names = names`;

create test_t from test[rowname=names];
append from test[rowname=names];
close test_t;
quit;