|
沙发

楼主 |
发表于 2005-4-7 11:32:02
|
只看该作者
重复啊重复
每次你们在不同的论坛贴同一个问题,我都要从一个论坛把回答再贴到另一个论坛。唉。
[code:3df62]
data old;
input ID$ Relationship Age Job $char1. Household;
cards;
101 1 50 2 1
102 3 24 6 1
103 1 34 3 2
105 3 4 . 2
106 3 6 . 2
107 5 47 1 2
;
run;
proc sql;
create table temp as
select age,job,household
from old
where relationship=1
;
select old.*,
case
when old.relationship=3 then temp.age
else .
end as ParentAge,
case
when old.relationship=3 then temp.job
else '.'
end as ParentJob
from old,temp
where temp.household=old.household and old.relationship<>1
;[/code:3df62] |
|