SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 610|回复: 1
打印 上一主题 下一主题

跟crackman读SAS程序(46)--读入数据中DELETE的应用

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-10-20 15:09:14 | 只看该作者

跟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 -->
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2010-10-20 17:27:48 | 只看该作者

Re: 跟crackman读SAS程序(46)--读入数据中DELETE的应用

推荐一下crackman的blog, 欢迎大家去踩 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-3 20:16 , Processed in 0.076691 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表