最后将观察添加到现有SAS数据集

时间:2016-10-19 23:23:18

标签: sas

我的数据集(名为A)有列:A B C.我想在其末尾添加新的观察结果(新行),其值为:1 2 3.必须有一种简单的方法可以做到这一点?

2 个答案:

答案 0 :(得分:3)

只需使用proc sqlinsert语句即可。

proc sql;
    insert into table_name (A,B,C) values (1,2,3);
quit;

答案 1 :(得分:1)

以下是另外5种方法:

/*Some dummy data*/

data have;
input A B C;
cards;
4 5 6
;
run;

data new_rows;
input A B C;
cards;
1 2 3
6 7 8
;
run;

/* Modifying in place - more efficient, increased risk of data loss */

proc sql;
    insert into have
    select * from new_rows;
quit;

proc append base = have data = new_rows;
run;

data have;
    modify have;
    set new_rows;
    output;
run;

/* Overwriting - less efficient, no harm if interrupted. */

data have;
    set have new_rows;
run;


data have;
    update have new_rows;
    /*N.B. assumes that A B C form a set of unique keys and that the datasets are sorted*/
    by A B C;
run;
相关问题