data have;
if _n_ = 1 then do;
input x1 $ x2 $;
delete;
end;
retain x1 x2;
input x3 $ x4 $@@;
if (anyalpha(x3) or anyalpha(x4)) then do;
x1 = x3; x2 = x4;
delete;
end;
cards;
a b
1 2 3 4
5 6 2 3
c d
1 3 4 5
;
运行之后的结果如下:
SAS 系统 2010年08月31日 星期二 上午01时10分10秒 1
Obs x1 x2 x3 x4
1 a b 1 2
2 a b 3 4
3 a b 5 6
4 a b 2 3
5 c d 1 3
6 c d 4 5
这里面最关键的是DELETE
Use the DELETE statement when it is easier to specify a condition that excludes observations from the data set or when there is no need to continue processing the DATA step statements for the current observation.
Use the subsetting IF statement when it is easier to specify a condition for including observations.
Do not confuse the DROP statement with the DELETE statement. The DROP statement excludes variables from an output data set; the DELETE statement excludes observations.