BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shynu
Fluorite | Level 6

I have a dataset:

 

idnamedmvalue
101weightds50
101weightds55
101weightds54
101weightds49.8
101weightds53

 

i need to output:

iddmweight
101ds50
101ds55
101ds54
101ds49.8
101ds53

 

 

using proc transpose how can i do it?

1 ACCEPTED SOLUTION

Accepted Solutions
collinelliot
Barite | Level 11

The following seems to work:

 

data have;
input id name $	dm $ value;
datalines;
101 weight ds 50
101 weight ds 55
101 weight ds 54
101 weight ds 49.8
101 weight ds 53
;

proc sort data = have;
    by id dm value;
run;

proc transpose data = have out = want;
    by id dm value;
    var value;
    id name;
run;

But why? Why not just rename "value" to "weight" and drop "name" if you really need that specific structure?

View solution in original post

2 REPLIES 2
collinelliot
Barite | Level 11

The following seems to work:

 

data have;
input id name $	dm $ value;
datalines;
101 weight ds 50
101 weight ds 55
101 weight ds 54
101 weight ds 49.8
101 weight ds 53
;

proc sort data = have;
    by id dm value;
run;

proc transpose data = have out = want;
    by id dm value;
    var value;
    id name;
run;

But why? Why not just rename "value" to "weight" and drop "name" if you really need that specific structure?

shynu
Fluorite | Level 6

thanx that worked

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1194 views
  • 1 like
  • 2 in conversation