r*****g 发帖数: 99 | 1 我想从whole dataset中找出在另外一个dataset的id,下面的code是错误的,请教如何
改正?
data two;
set whole;
if id is in dataset1 then status=1;
else status=2;
run;
不胜感激! |
k*******a 发帖数: 772 | |
b********r 发帖数: 764 | 3 proc sort data=whole;
by id;
run;
proc sql;
create dataset2 as select distinct id from dataset1;
quit;
proc sort data=dataset2;
by id;
run;
data two;
merge(in=a) whole dataset2(in=b);
by id;
if a;
if b then status=1;
else status=2;
run;
【在 r*****g 的大作中提到】 : 我想从whole dataset中找出在另外一个dataset的id,下面的code是错误的,请教如何 : 改正? : data two; : set whole; : if id is in dataset1 then status=1; : else status=2; : run; : 不胜感激!
|
s*******e 发帖数: 1385 | 4 proc sql;
create table temp as
select * from whole
where id in (select distinct id from dataset1);
quit;
【在 r*****g 的大作中提到】 : 我想从whole dataset中找出在另外一个dataset的id,下面的code是错误的,请教如何 : 改正? : data two; : set whole; : if id is in dataset1 then status=1; : else status=2; : run; : 不胜感激!
|
d****3 发帖数: 65 | 5 proc sql;
update whole set status=case when exists(select 1 from dataset1 where
dataset1.id=whole.id) then 1 else 2 end;
quit; |
D**u 发帖数: 288 | 6 Nice, learned something!
【在 d****3 的大作中提到】 : proc sql; : update whole set status=case when exists(select 1 from dataset1 where : dataset1.id=whole.id) then 1 else 2 end; : quit;
|