楼主: 3qsir
1434 5

[有偿编程] Replace Missing Value to another string [推广有奖]

  • 2关注
  • 1粉丝

副教授

52%

还不是VIP/贵宾

-

威望
0
论坛币
13606 个
通用积分
3.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
71839 点
帖子
368
精华
0
在线时间
931 小时
注册时间
2011-5-18
最后登录
2021-3-6

5论坛币
Dear Sir : Can you help me to replace missing value to last ID name (only)
fo rexample, I want to replace the first missing value into B104, then the 2nd missing vale into B110.
Sincerly !

ID      xret     did       ear
A101     22       3         2
A103     02       5         1
B104     09       3         1
.           01       1         2
B107     12       4         3
B108     11       5         4
B110     06       7         7
.           07       6         3
B112     78       2         6
-----------------------------------
I hope result:
ID      xret     did       ear
A101     22       3         2
A103     02       5         1
B104     09       3         1
B104     01       1         2
B107     12       4         3
B108     11       5         4
B110     06       7         7
B110     07       6         3
B112     78       2         6
关键词:replace missing Another string Other another replace
沙发
intheangel 学生认证  发表于 2014-6-10 17:21:53 |只看作者 |坛友微信交流群
  1. data a;
  2. input ID $    xret     did       ear;
  3. cards;
  4. A101     22       3         2
  5. A103     02       5         1
  6. B104     09       3         1
  7. .           01       1         2
  8. B107     12       4         3
  9. B108     11       5         4
  10. B110     06       7         7
  11. .           07       6         3
  12. B112     78       2         6
  13. ;
  14. run;
  15. data a;
  16. set a;
  17. id_lag=lag(id);
  18. if id='' then id=id_lag;
  19. drop id_lag;
  20. run;
复制代码

使用道具

藤椅
3qsir 发表于 2014-6-10 22:36:11 |只看作者 |坛友微信交流群
If missing value are sequential at least 2 id foe example :
ID      xret     did       ear
A101     22       3         2
A103     02       5         1
B104     09       3         1
.           01       1         2
.            12       4         3
B108     11       5         4
B110     06       7         7
.           07       6         3
B112     78       2         6
-----------------------------------
I hope to  result:
ID      xret     did       ear
A101     22       3         2
A103     02       5         1
B104     09       3         1
B104     01       1         2
B104     12       4         3
B108     11       5         4
B110     06       7         7
B110     07       6         3
B112     78       2         6
---------------------------------------
It is follow you code results , but missing value still exist in column id

ID      xret     did       ear
A101     22       3         2
A103     02       5         1
B104     09       3         1
B104     01       1         2
  .          12       4         3
B108     11       5         4
B110     06       7         7
B110     07       6         3
B112     78       2         6


使用道具

板凳
acode 发表于 2014-6-11 00:00:11 |只看作者 |坛友微信交流群
data a;
set a;
retain temp;
if id ne . then temp=id;
else id=temp;drop temp;
run;

使用道具

报纸
acode 发表于 2014-6-11 00:00:45 |只看作者 |坛友微信交流群
data a;
set a;
retain temp;
if id ne . then temp=id;
else id=temp;drop temp;
run;

使用道具

地板
luolxy 发表于 2014-6-12 10:36:42 |只看作者 |坛友微信交流群
dewrewr4

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-29 02:05