• SAS--chapter12( SAS 数据集的读写)


      

    libname clinic 'D:sas';
    data lab23.drug1h(drop=placebo uric);
    set research.cltrials(drop=triglyc);
    if sex='M' then delete;
    if placebo='YES';
    TestDate='22MAY1999'd;
    retain Days 30;
    days+1;
    length Retest $ 5;
    if cholesterol>190 then retest='YES';
    else if 150<=cholesterol<=190 then retest='CHECK';
    else if cholesterol<150 then retest='NO';
    label retest='Perform Cholesterol Test 2?';
    format enddate mmddyy10.;
    run;
    
    data clinic.data1017(drop=sex);
        set sasuser.diabetes(keep=age sex);  *想根据if筛观测单位,又不想要这个变量,drop和keep必须都要有sexif sex='F';                *如果只有drop有sex,dara2017里只有一个变量名,无observation;
    run;
    
    *proc sort  out  by (排序)
    print by  (subtotal)
    data by (排序);
    proc sort data=clinic.data1016 out=data;
    by height;
    run;
    data data1;
        set data;
        by height;   *by之前,该变量必须已经被排序了??//有一个appropriate index;
    run;
    
    * 查看一个单位;
    data data2;
        obsnum=5;
        set clinic.admit point =obsnum;
        output;   *没有output和stop,无限循环;有stop,无output,空数据集;;
                *有output无stop,无限多个第五观察值;
    run;            *输入文件会有一个end-of-file marker,但是point指定了一个变量,则没有这个marker,所以需要stop;
    
    data data3 data4;    *同时创建两个data set ,只有output中的data有内容;
        set clinic.admit;
        output data3;
    run;
    
    data data5;
        set clinic.admit end=last;  *读累加后变量(he)的最后一个值=总计;
        he+height;                    *end 和point不能在同一step;
        we+weight;
        fe+fee;
        if last;
    run;
    proc sort data=company.usa out=work.temp2;
            by manager jobtype;
         data company.budget2(keep=manager jobtype payroll);
            set work.temp2;
            by manager jobtype;
            if wagecat='S' then Yearly=wagerate*12;
            else if wagecat='H' then Yearly=wagerate*2000;
            if first.jobtype then Payroll=0;
            payroll+yearly;
            if last.jobtype;
         run;
    
         data work.getobs5(drop=obsnum);
            obsnum=5;
            set company.usa(keep=manager payroll) point=obsnum;
            output;
            stop;
         run;
    
         data work.addtoend(drop=timemin timesec);
            set clinic.stress2(keep=timemin timesec) end=last;
            TotalMin+timemin;
            TotalSec+timesec;
            TotalTime=totalmin*60+timesec;
            if last;
         run;
     libname clinic 'c:stresslabdata';
         options nodate number pageno=15;
         proc sort data=clinic.stress out=work.maxrates;
            by maxhr;
         run;
         proc print data=work.maxrates label double noobs;
            id name;
            var resthr maxhr rechr date;
            where tolerance='I' and resthr>90;
            sum fee;
            label rechr='Recovery HR';
         run;
         title 'August Admission Fees';
         footnote 'For High Activity Patients';
         proc print data=clinic.admit label;
            var actlevel fee;
            where actlevel='HIGH';
            label fee='Admission Fee';
            format fee dollar4.;
         run;
    Valar morghulis
  • 相关阅读:
    struct中的字段顺序的大小
    go web之CSRF库的使用方式和实现原理
    Go进阶23:Go指针返回值的劣势(译)
    16 Transformer 的编码器(Encodes)——我在做更优秀的词向量
    13 MultiHead SelfAttention(从空间角度解释为什么做多头)
    07 预训练语言模型的下游任务改造简介(如何使用词向量)
    11 SelfAttention相比较 RNN和LSTM的优缺点
    1401 位置编码公式详细理解补充
    08 ELMo模型(双向LSTM模型解决词向量多义问题)
    09 什么是注意力机制(Attention )
  • 原文地址:https://www.cnblogs.com/super-yb/p/11693175.html
Copyright © 2020-2023  润新知