标题: easy line [打印本页] 作者: shiyiming 时间: 2005-4-17 00:40 标题: easy line hi...
i have a simple question about how to creat a new var.
"d1" is a original var. and i want to have a new var "d2" orderly
and d3 depending on d1 obs
such as below example:
d1 d2 d3
q 1 4
q 2 4
q 3 4
q 4 4
w 1 3
w 2 3
w 3 3
r 1 2
r 2 2
t 1 4
t 2 4
t 3 4
t 4 4
any suggestion will very appreciate..thx作者: shiyiming 时间: 2005-4-17 09:07 标题: it is done [code:88c2d]
data ahuige;
input d1 $;
cards;
q
q
q
q
w
w
w
r
r
t
t
t
t
;
run;
proc sort;
by d1;
run;
data ahuige;
set ahuige;
n=_n_;
run;
proc sql;
create table final as
select d1,(n-min(n)+1) as d2,count(*) as d3
from ahuige
group by d1
order by d1,n
;
quit;
[/code:88c2d]