BookmarkSubscribeRSS Feed
smilegirl01
Calcite | Level 5

I'm very new to sas and I'm having quite a bit of trouble with reformatting a data set I have. 

 

I'm using a small data set that contains an id number and then scores for reading, spelling, math, science. The first line of the data set is set up as follows:

 

id  reading  spelling  math  science
 1       45        38    31       42

I would like to reformat it using a data step to look like this: 

id       type      score
 1    reading         45
 1   spelling         38
 1       math         31 
 1    science         42

Thank you for any advice in the right direction!

1 REPLY 1
novinosrin
Tourmaline | Level 20
data have;
input id  reading  spelling  math  science;
cards;
 1       45        38    31       42
 ;

proc transpose data=have out=want(rename=(_name_=Type col1=score));
by id;
var reading--science;
run;