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,还有其他的方法吗?