码迷,mamicode.com
首页 > 其他好文 > 详细

SAS--chapter12

时间:2019-10-17 17:43:37      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:多个   sub   obs   iat   end   ota   div   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=22MAY1999d;
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;

 

SAS--chapter12

标签:多个   sub   obs   iat   end   ota   div   sas   文件   

原文地址:https://www.cnblogs.com/super-yb/p/11693175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!