wdxmahone 发表于 2011-7-14 13:33 
3# pobel
您好,有几个问题,
1. 这里还是使用了SAS,我只想用SQL程序,用sql_server软件做,没法使用SAS程序;
2. 如果x2是字符型的应该怎么弄。
谢哈
This query can solve your question 2).
data a;
input X1 $ X2;
if ^missing(x2) then flag+1;
cards;
01 10
01 .
01 .
01 20
01 .
02 100
02 .
02 120
02 .
02 140
02 .
;
proc sql;
create table b as
select t.x1,s.x2
from a t
left join
(select x1, x2, flag
from a
where x2 ne . ) s
on t.x1=s.x1 and t.flag=s.flag
;
quit;
proc print;run;