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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.