sas 组内序列号

Table1. Adverse Events
ID var1 var2 
01 Y Cancer
01 Y Death
01 Y Prolongs Hospitalization
01 Y Life Threatening
02 N Overdose
02 N Death
02 N Disability
02 N Cancer
02 N Other

 

Table2. Adverse Events
ID ID1 var1 var2 
01 1 Y Cancer
01 2 Y Death
01 3 Y Prolongs Hospitalization
01 4 Y Life Threatening
02 1 N Overdose
02 2 N Death
02 3 N Disability
02 4 N Cancer
02 5 N Other

数据管理:插入新变量ID1:按ID分组,每组用ID1顺序编号(如表2);table1数据集命名为ae,table1数据集命名为ae1。

sample sas code:

proc sort  data=ae out=ae0;

    by id;

run;

data ae1;

    set ae0;

    by id;

    if first.id then id1=1;

    else id1+1;

run;

上一篇:HDU 6136 Death Podracing (堆)


下一篇:Peace, Death for Mac 下载 – 好玩的街机模拟风格益智游戏