Help using Base SAS procedures

Transpose..

Reply
Super Contributor
Posts: 1,041

Transpose..

Transpose

I have a dataset like shown below....

meas_ID has a description

for example 101 means temp

102 means BP ete etc

a patient might have different  readings on the same day for the same measID

What is the best way to transpose this dataset

in this example you can take:

101 for Temperature

102 for BP

But I have numerous vitals like that and numerous times....

Thanks

pt_Id     meas_ID      value       name    date

999          101             98.9         bond      23mar2012

999          102           80/120     bond       25mar2012

  999          101            97.6         bond      23mar2012

999            101            97.7        bond       23mar2012 

Super Contributor
Posts: 1,041

Re: Transpose..

Posted in reply to robertrao

Do you think it is a good idea to create a new variable with the descriptions of the meas_ID?

and exporting all Temperature,s across all patients to a seperate dataset and then BP also like that???????

Regards

Super Contributor
Posts: 1,041

Re: Transpose..

Posted in reply to robertrao

When I try to do this :

I GET

ERROR: The ID value "_xxxxxxxxx" occurs twice in the same BY group.

proc transpose data=check;

by mrn last_name first_name enc_id admission_date discharged;

var VALUE;

id meas_ID;

run;

Super Contributor
Posts: 418

Re: Transpose..

Posted in reply to robertrao

You get this because by definition an ID with a tranpose step has to be distinct, and yours are not.  NOte that for the same day, you have an id of 101, 101, 101 with 3 different registered values. This will not make sense in a tranpose, because what value would it report for your ID variable of 101?

I do not believe a tranpost is actually what you want, however maybe I am misunderstanding your comments. Would you be able to post a sample of your Before and After data, that way I can better understand what you are asking for?

Did you want the following data output by chance? (I made up my own data, but it gets the point across)

Patient ID     Value

101                    98.6

101                    100.1

101                    101.35

TO become

Patient ID          Value1     Value2     Value3

101                      98.6          100.1        101.35

If so, just add a counter to your dataset (counter=_N_) and then add the counter to your tranpose statement. The order that the data is in will be the order that is maintained amongst your tranposed dataset.

Let me know if this is not what you wanted.

Thanks!

Super Contributor
Posts: 1,041

Re: Transpose..

Posted in reply to Anotherdream

Could you please show how do I adda counter to my transpose step?

Thanks

Super Contributor
Posts: 418

Re: Transpose..

Posted in reply to robertrao

If what I showed was indeed what you needed, you actually don't need an ID step. You can just do the following.

proc sort data=YOURDATA;

meas_id;

run;

proc tranpose data=YOURDATA out=newdata;

by meas_id;

var value;

run;

Let me know if that is not the results you wanted to get.

Ask a Question
Discussion stats
  • 5 replies
  • 191 views
  • 0 likes
  • 2 in conversation