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;

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 1571 views
  • 3 likes
  • 2 in conversation