data want;
set have;
array s score1-score5;
do i=1 to dim(s);
score=s(i);
output;
end;
drop i score1-score5;
run;
data want;
set have;
array s score1-score5;
do i=1 to dim(s);
score=s(i);
output;
end;
drop i score1-score5;
run;
Hi @Feyng819,
You can also use PROC TRANSPOSE:
proc transpose data=have out=want(drop=_: rename=(col1=score) where=(score>.));
by name notsorted;
var score:;
run;
That is what PROC TRANSPOSE was made for.
You can use RENAME= dataset option to change the name it assigns to the new variable to something more meaningful.
proc transpose data=have out=want(rename=(col1=SCORE) );
by name;
var score1-score5;
run;
No need to LOOP. You can just write some wallpaper code.
data want;
set have;
score=score1;
output;
score=score2;
output;
.....
run;
You can complete the pattern.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.