SAS 仅插入到数据集中的第一行(示例)数组



我有点问题。我只需要插入到数组(示例(第一个数组,最好逐个字段。我该怎么做?如果您也指出如何逐列插入,我将不胜感激(我将来能够加载选定的列(。

data have;
infile DATALINES dsd missover;
input varr1 varr2 varr3;
CARDS;
1, 2, 3
2, 3, 4 
5, 4
4, 3
9, 4, 1
6,
;run;
data want;
   set have;
    array L[3] _temporary_ ;
if _n_ = 1 then 
    do;
        do i = 1 to 3;
            %LET j = i;
            L[i] = varr&i;  /*in this place I have problem*/
            put L[i];
        end;
    end;
run;

你不需要宏,也不知道为什么需要临时数组L

数组

语句可用于组织变量,以便能够以数组方式访问它们。 循环遍历变量数组,以便将值复制到临时数组中。

临时数组的元素不可用于输出,并且不是将变量重置为缺失的正常隐式程序数据向量 (PDV( 行为的一部分。

data want;
  set have;
  array V varr1-varr3;
  array L[3] _temporary_;
  * save first rows values in temporary array for use in other rows;
  if _n_ = 1 then 
    do index = 1 to dim(V);
      L[index] = V[index];
    end;
  * … for example … ;
  array delta_from_1st [3];  * array statement implicitly creates three new variables that become part of PDV and get output;
  do index = 1 to dim(V);
    delta_from_1st[index] = V[index] - L[index];
  end;      
run;

最新更新