SAS中文论坛

标题: 跟crackman读SAS程序(46)--读入数据中DELETE的应用 [打印本页]

作者: shiyiming    时间: 2010-10-20 15:09
标题: 跟crackman读SAS程序(46)--读入数据中DELETE的应用
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.
转自博客:
<!-- m --><a class="postlink" href="http://hi.baidu.com/crack_man/home">http://hi.baidu.com/crack_man/home</a><!-- m -->
作者: shiyiming    时间: 2010-10-20 17:27
标题: Re: 跟crackman读SAS程序(46)--读入数据中DELETE的应用
推荐一下crackman的blog, 欢迎大家去踩 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2