/* test data */
data one;
input score1 - score3;
cards;
11 12 13
21 . 23
. 32 33
. . 43
51 . .
. . 63
. . .
;
run;
/* "compact" the scores by bubbling non-missings to the left */
data two;
set one;
array scores score1-score3;
drop i j temp;
do i = 1 to 3-1;
do j = 3 to i+1 by -1;
if missing(scores(j-1)) and not missing(scores(j)) then do;
temp = scores(j-1);
scores(j-1) = scores(j);
scores(j) = temp;
end;
end;
end;
run;
/* check */
proc print data=two;
run;
/* on lst
Obs score1 score2 score3
1 11 12 13
2 21 23 .
3 32 33 .
4 43 . .
5 51 . .
6 63 . .
7 . . .
*/
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: