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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.