全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1307 3
2018-01-28
请问如何做到搜索一个表格中所有空值,并且把空值填充为列表名字?

比如说:
表格:
A B C D E
2 4    5 5
3    4 6  

希望做到的结果:

A B C D E
2 4 C 5 5
3 B 4 6 E



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-1-29 12:10:56
可以用一个序列ARRAY在加VNAME函数完成。
以下是Sample Code:
data want;
set have;
array x(*) A B C D E;
do i=1 to dim(x);
if missing(x(i)) then x(i)=vname(x(i)) ;
end;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-1-31 04:12:14
The question is not clear itself.  It seems that you have data with 5 columns and there are missing values in some of columns. and you want to fill with values :  first column with A, second one with B, etc.

If that is case, it is pretty easy: you can use array if you have many columns to fix.  In you example,
you can simply use some ifthen statement:
   if  col_A is  ''  then col_A = "A" ;
   if  col_B is  ''  then col_B = "B" ;
   if  col_C is  ''  then col_C = "C" ;
   if  col_D is  ''  then col_D = "D" ;
   if  col_E is  ''  then col_E = "E" ;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-2-20 11:47:40
变量类型是数值型,字母是字符型,怎么填充?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群