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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 636 views
  • 3 likes
  • 2 in conversation