SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

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

上机中出现的一个问题,请求高手解答

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2006-4-7 21:11:07 | 只看该作者

上机中出现的一个问题,请求高手解答

DATA work.ex1(drop=type);
        infile datalines dlm='';
        retain address;
        input @5 type $1. @;
        if upcase(type)='H' then input @7 address $15.;
        if upcase(type)='P' then input @7 name $8. @15 age 2. @18 dep $8.;
        datalines;
    H cqu
        P asd     24 computer
        P wangyi  25 computer
        P danjie  24 chemical
        H pekingu
        P fengyan 65 chemical
        P wuyu    54 telecom
        P feifei  24 telecom
        H tsinghua
        P kuai    22 computer
        P wudi    22 chemical
        ;
run;
proc print;
run;
输出:
                            Obs    address     name       age      dep
                                           1    cqu                      .
                                           2    cqu         asd         24    computer
                                           3    cqu         wangyi      25    computer
                                           4    cqu         danjie      24    chemical
                                           5    pekingu                  .
                                           6    pekingu     fengyan     65    chemical
                                           7    pekingu     wuyu        54    telecom
                                           8    pekingu     feifei      24    telecom
                                           9    tsinghua                 .
                                          10    tsinghua    kuai        22    computer
                                          11    tsinghua    wudi        22    chemical
求助:
如何去掉OBS1。5。9这三行观测直?书上这段类似程序就没有1。5。9这三行观测。
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2006-4-12 10:10:50 | 只看该作者

RE:

DATA work.ex1(drop=type);
infile datalines dlm='';
retain address;
input @5 type $1. @;
if upcase(type)='H' then input @7 address $15.;
if upcase(type)='P' then do;input @7 name $8. @15 age 2. @18 dep $8.; output;end;
datalines;
    H cqu
    P asd     24 computer
    P wangyi  25 computer
    P danjie  24 chemical
    H pekingu
    P fengyan 65 chemical
    P wuyu    54 telecom
    P feifei  24 telecom
    H tsinghua
    P kuai    22 computer
    P wudi    22 chemical
;
run;
proc print;
run;
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-9 22:06 , Processed in 0.067310 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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