[code:9a20f]declare @sex char(2), @age char(2),
@i int
declare cur_group cursor
for
select sex,age from tbl group by sex, age
for read_only
open cur_group
fetch next from cur_group into @sex, @age
set @i = 1
while @@fetch_status = 0
begin
update tbl set gid = @i where sex=@sex and age=@age
fetch next from cur_group into @sex, @age
set @i = @i + 1
end
close cur_group
deallocate cur_group [/code:9a20f]作者: shiyiming 时间: 2004-9-16 09:06 标题: test 不明白你的gid,依次累加是什么意思?
我有一个解法
[code:e5f31]proc sort data=tem;
by sex age;
data tem1;
retain no 0;
set tem;
by a b;
flag=no;
if last.b then no+1;
run;
proc sql;
create table tem3 as
select count(flag) as c,sex,age
from tem2
group by flag;
quit;[/code:e5f31]作者: shiyiming 时间: 2004-9-16 11:54 标题: 感谢gbt 你提供的代码的确很简单,对我很有启发,多谢!