Help using Base SAS procedures

convert multiple variable dataset into multiple record dataset

Reply
New Contributor
Posts: 4

convert multiple variable dataset into multiple record dataset

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: 

IDGrade_Wave1Score_Wave1Score_Wave2Score_Wave3
PL240812G15587
PL240812G24589
PL240813G15588
PL240815G16589
PL240817G17599

 

 

I want to convert the data to this: 

IDSchoolGrade_Wave1Score_Wave123Wave
PL240812G11551
PL240812G11582
PL240812G11573
PL240812G21451
PL240812G21482
PL240812G21493
PL240813G12551
PL240813G12582
PL240813G12583
PL240815G12651
PL240815G12682
PL240815G12693
PL240817G13751
PL240817G13792
PL240817G13793
Super User
Posts: 5,083

Re: convert multiple variable dataset into multiple record dataset

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;

Ask a Question
Discussion stats
  • 1 reply
  • 126 views
  • 0 likes
  • 2 in conversation