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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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