全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1346 2
2012-09-27
there are two ways:
data test;
  infile datalines truncover dsd dlm=' ';
  input t1 $ t2 $ t3 $ t4 $ t5 $;
datalines;
test1 test2 test3  . test5
. test2 test3 test4 test5
test1 . test3 . test5
test1 . .  test4 .
test1 test2 test3 test4 test5
;
run;

/* 1  Use ARRAY processing to assign non-missing values into new variables */
data shift1 (drop=t1-t5 j i);
  set test;
  array in t1-t5;
  array out $ o1-o5;
  j=1;
  do i=1 to 5;
    if in(i) ne ' ' then do;
      out(j)=in(i);
      j+1;
    end;
  end;
run;
proc print;
run;

/*2  using catx*/
%macro shift2;
proc contents data = test out = test1(keep = name) noprint;
run;
proc sql noprint;
select count(name) into: n from test1;
quit;
%let n=%eval(&n.);
data shift5;
set test;
t=catx('#',of t1-t&n);
%do i=1 %to &n;
t&i.=scan(t,&i.,'#');
%end;
drop t;
run;
%mend shift2;
%shift2;

只想到这两种方法,除了用array 和 catx,还有其他的方法吗?
二维码

扫码加我 拉你入群

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

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

全部回复
2012-9-27 09:58:07
其实多少无所谓,因为你已经枚举了最好的两种。京剧
二维码

扫码加我 拉你入群

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

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

2012-9-27 10:01:36
我还想找出尽可能多的方法来share,但是知识有限,求赐教!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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