Help using Base SAS procedures

Transpose

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

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
Respected Advisor
Posts: 4,919

Re: Transpose

Posted in reply to robertrao

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

View solution in original post


All Replies
Solution
‎04-21-2013 10:02 PM
Respected Advisor
Posts: 4,919

Re: Transpose

Posted in reply to robertrao

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,020

Re: Transpose

Posted in reply to robertrao

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

Posted in reply to robertrao

It works fine.

I have a question though..

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

Regards

Respected Advisor
Posts: 4,919

Re: Transpose

Posted in reply to robertrao

You can skip sorting only if the patient data (IDs) are consecutive (grouped together) in your dataset. - PG

PG
🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 203 views
  • 6 likes
  • 3 in conversation