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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1291 views
  • 1 like
  • 2 in conversation