SAS中文论坛

标题: 如何将观测号(即行号)作为sql select的限定条件 [打印本页]

作者: shiyiming    时间: 2008-10-7 17:21
标题: 如何将观测号(即行号)作为sql select的限定条件
语句如下:

proc SQL;
create view ynb2.count5 as
          select '最近1年内' as tenor, count3_z.COL1 as CDL from ynb2.count3_z where obs=1
    union all select '最近6月内' as tenor, count3_z.COL1 as CDL from ynb2.count3_z where obs=2
    union all select '最近3月内' as tenor, count3_z.COL1 as CDL from ynb2.count3_z where obs=3
    union all select '最近1月内' as tenor, count3_z.COL1 as CDL from ynb2.count3_z where obs=4;

本想以为观测号OBS=可以作为条件,但运行不了

请指教,用观测号作为限定条件应该怎么写
作者: shiyiming    时间: 2008-10-8 11:43
标题: Re: 如何将观测号(即行号)作为sql select的限定条件
data ynb2.count5;
        set ynb2.count3_z;
        if _n_ in (1,2,3,4) then
        output;
run;
作者: shiyiming    时间: 2008-10-10 08:24
标题: Re: 如何将观测号(即行号)作为sql select的限定条件
replace 'obs' with 'monotonic()'




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2