04-29-2013 04:39 PM
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....
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
04-29-2013 04:46 PM
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???????
04-29-2013 04:57 PM
When I try to do this :
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;
04-29-2013 05:32 PM
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
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.
04-29-2013 05:50 PM
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;
proc tranpose data=YOURDATA out=newdata;
Let me know if that is not the results you wanted to get.