0
有人会确认COALESCE或COALESCEC功能是否适用于以下的正确命令?使用COALESCEC填充缺失值
我想从一个非缺失相应的观察值到一个缺失观察值的匹配值。
所以,如果数据是这样的:
Order | ID
apple 101xa
orange 201xb
cherry 301xc
apple .
我将结束:
Taxo | Specialty2
apple 101xa
orange 201xb
cherry 301xc
apple 101xa
感谢您的支持!
编辑:目前代码used--
proc sort data=fill;
by taxo descending specialty2;
run;
data fill_input;
set fill;
retain tempspecialty2;
length tempspecialty2 $5;
by taxo;
if first.taxo then tempspecialty2=' ';
if not missing(specialty2) then tempspecialty2=specialty2;
else tempspecialty2=specialty2;
run;
proc freq data=fill_input;
table tempspecialty2;
run;
我该如何控制以确保第一个“订单”与缺少“ID”不符? 或者有没有办法创建一个新的变量,'ID'? – Jebediah15
这取决于你的规则 - 即,如果你有多个,你怎么知道哪一个是正确的?如果你不在乎,只想要任意的ID被填入,那么按'order descending id'排序'',这会在底部放置缺失的ID。 – Joe
谢谢乔!输入已经被验证,所以它真的是关注失踪的。但是,我使用了,我认为是适应的代码,它似乎没有纠正丢失的obs。任何见解? – Jebediah15