## Transpose

Solved
Super Contributor
Posts: 1,041

# Transpose

Hi,

I have a table like this...

pt no  ID    value

111  101  96.4

111 102  80/120

For the same patient 111 the ID values are different.

ID value 101 is Temperature and 102 is BP..

How can i get the information in a single row??????/

Regards

Accepted Solutions
Solution
‎04-21-2013 10:02 PM
Posts: 5,529

## Re: Transpose

Transpose is the question, and the answer!

data have;
length value \$10;
input pt_no ID value;
datalines;
111  101  96.4
111 102  80/120
;

proc transpose data=have out=want(drop=_name_) prefix=code_;
by pt_no notsorted;
var value;
id ID;
run;

proc print; run;

PG

PG

All Replies
Solution
‎04-21-2013 10:02 PM
Posts: 5,529

## Re: Transpose

Transpose is the question, and the answer!

data have;
length value \$10;
input pt_no ID value;
datalines;
111  101  96.4
111 102  80/120
;

proc transpose data=have out=want(drop=_name_) prefix=code_;
by pt_no notsorted;
var value;
id ID;
run;

proc print; run;

PG

PG
Super User
Posts: 10,782

## Re: Transpose

You'd better post the result you need . Is it what you are looking for ?

```data have;
input pt  ID    value : \$20.;
cards;
111  101  96.4
111 102  80/120
;
run;
data want(keep=pt x);
set have;
by pt;
length x \$ 40;
retain x;
x=catx(' ',x,id,value);
if last.pt then do;
output;
call missing(x);
end;
run;

```

Ksharp

Super Contributor
Posts: 1,041

## Re: Transpose

It works fine.

I have a question though..

notsorted : can i use this with the by statement and skip the proc sort step?????

Regards

Posts: 5,529