Thank you! I need data and I was able to figure this out using proc means and proc transpose using the following code:
PROC MEANS DATA=mod_data NWAY NOPRINT;
CLASS study_id activity;
VAR HR;
OUTPUT
OUT = SUMS
MEAN = M_HR; RUN;
proc transpose data=SUMS_test(drop=_type_ _freq_)
out=transposed_hrm(drop=activity _label_)
name=activity prefix=ACT
suffix=HRM;
by study_id;
var M_HR;
run;
However, I am running into one issue that I've run into in the past which is why I had initially asked this questions. The transpose creates 6 new variables (act1hrm-act6hrm). When I transpose the data is puts each participants information in consecutive variables. For example, if a participant has HR data for activity 1, 3, and 5, the transpose puts the data in the act1hrm, act2hrm, and act3hrm instead of act1hrm, act3hrm, and act5hrm where the data should be placed. I hope this makes sense.
Previously, when I was doing something similar I used the solution below as suggested by another user to concatenate variables before transposing. However, this does not seem to work when modifying the code to use the HR variable, which is continuous, instead of the hrzone variable, which only has 3 categories. I am likely not doing something correctly and I know I need to read up on proc means more, which I am doing. But I can't seem to figure this out. Any help would be greatly appreciated.
proc means data=mod_data n completetypes;
var indicator;
class study_id activity hrzone;
types study_id*activity*hrzone;
output out=acthr_summary n=acthr;
title 'Time in activity by hrzone level for each participant';
run;
proc contents data=acthr_summary;
run;
* concatenate 'ACTHR', activity, hrzone, and 'T' to use when
* naming variable after transpose ;
data acthr_summary_with_combo;
length combo $ 8;
set acthr_summary(drop=_type_ _freq_);
combo=cat('ACTHR',activity,hrzone,'T');
run;
proc contents data=acthr_summary_with_combo;
run;
proc transpose data=acthr_summary_with_combo(drop=activity hrzone)
out=transposed_acthr(drop=_name_);
by study_id;
var acthr;
id combo;
run;
... View more