Help using Base SAS procedures

Help with Transposing the data

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 127
Accepted Solution

Help with Transposing the data

I have the following data:

data have;

input id $1.   prd_id  $2.   prd  $3. seq    rx;

cards;

1   12    xyz  1    8

1   12    xyz  2    5

1   12    xyz  3    7

1   12    xyz  4    8

1   13    abc  2    5

1   13    abc  3    4

1   13    abc  5    9

I want the output as follows:

id   prd_id    prd    rx1   rx2  rx3  rx4   rx5

1      12      xyz     8     5     7      8     .

1      13      abc     .      5     4      .     9


Accepted Solutions
Solution
‎07-28-2015 12:39 PM
Super User
Posts: 19,792

Re: Help with Transposing the data

Straightforward proc transpose, remember to sort first.

proc transpose data=have out=want prefix=rx;

by id prd_id prd;

var rx;

id seq;

run;

View solution in original post


All Replies
Solution
‎07-28-2015 12:39 PM
Super User
Posts: 19,792

Re: Help with Transposing the data

Straightforward proc transpose, remember to sort first.

proc transpose data=have out=want prefix=rx;

by id prd_id prd;

var rx;

id seq;

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 239 views
  • 0 likes
  • 2 in conversation