I have a repeated measures dataset with mutiple variables (i.e., one variable per wave of data collection; Wave1_score, Wave2_score, Wave3_score). Is there a way to convert the data to multiple records (i.e., one row per data collection).
Thank you!
This is an example of what I have now:
ID | Grade_Wave1 | Score_Wave1 | Score_Wave2 | Score_Wave3 |
PL240812G1 | 5 | 5 | 8 | 7 |
PL240812G2 | 4 | 5 | 8 | 9 |
PL240813G1 | 5 | 5 | 8 | 8 |
PL240815G1 | 6 | 5 | 8 | 9 |
PL240817G1 | 7 | 5 | 9 | 9 |
I want to convert the data to this:
ID | School | Grade_Wave1 | Score_Wave123 | Wave |
PL240812G1 | 1 | 5 | 5 | 1 |
PL240812G1 | 1 | 5 | 8 | 2 |
PL240812G1 | 1 | 5 | 7 | 3 |
PL240812G2 | 1 | 4 | 5 | 1 |
PL240812G2 | 1 | 4 | 8 | 2 |
PL240812G2 | 1 | 4 | 9 | 3 |
PL240813G1 | 2 | 5 | 5 | 1 |
PL240813G1 | 2 | 5 | 8 | 2 |
PL240813G1 | 2 | 5 | 8 | 3 |
PL240815G1 | 2 | 6 | 5 | 1 |
PL240815G1 | 2 | 6 | 8 | 2 |
PL240815G1 | 2 | 6 | 9 | 3 |
PL240817G1 | 3 | 7 | 5 | 1 |
PL240817G1 | 3 | 7 | 9 | 2 |
PL240817G1 | 3 | 7 | 9 | 3 |
Assuming that SCHOOL is actually part of your data set, here's a way:
data want;
set have;
array scores {3} score_wave1 - score_wave3;
do wave=1 to 3;
score_wave123 = scores{wave};
output;
end;
drop score_wave1 - score_wave3;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.