合并 sas 数据集中在 header 中具有列 "shiyas" 的所有列

merging all columns in sas dataset who has column "shiyas" in header

我有一个包含 shiyas1shiyas2shiyas3 列的 sas 数据集。该数据集还有其他一些列。我想将所有带有 header 和 shiyas 的列组合起来。

我们不能使用 cats(shiyas1,shiyas2,shiyas3),因为类似的数据集最多有 shiyas10 列。因为我正在生成通用的 sas 代码,所以我们不能使用 cats(shiyas1,shiyas2 .... shiyas10)

那么我们该怎么做呢?

当我尝试使用 cats(shiyas1,shiyas2 .... shiyas10) 时,尽管我的数据集最多包含 shiyas3 列,但它创建了 shiyas4shiyas10 列并填充了 .他们。

所以一种解决方案是合并 shiyas 直到数据集有或删除不必要的 shiyas 列...

请帮助我。

of 语句(允许您跨行读取,类似于数组)与 : 通配符一起使用。这将连接所有以 'shiyas'

开头的列

cats(of shiyas:)

使用变量列表。

data have;
    input (shiyas1-shiyas3) (:.);
    cards;
 1 2 3
 ;

data want;
    set have;
    length cat_shiyas $ 100 /*large enough to hold the content*/
    ;
    cat_shiyas=cats(of shiyas:);
run;