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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.