SAS中文论坛

标题: 上机中出现的一个问题,请求高手解答 [打印本页]

作者: shiyiming    时间: 2006-4-7 21:11
标题: 上机中出现的一个问题,请求高手解答
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这三行观测。
作者: shiyiming    时间: 2006-4-12 10:10
标题: 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;




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