Hello all,
Many thanks for helping me to convert the first design to the second design.
Id B w g
1 8 . .
1 7 . .
1 . 6 .
1 . 5 .
1 . . 4
1 . . 5
2 4 . .
2 3 . .
2 . 6 .
2 . 2 .
2 . . 8
2 . . 4
.
.
.
Second design: the number here is the mean number of each event (B,w,g ) for each id_recoded
Id B w g
1 7.5 5.5 4.5
2 3.5 4 6
.
.
.
Thank you in advance
Proc summary data=have nway; class id; var b w g; output out=want (drop= _: ) mean=; run;
Looks likely.
The NWAY means that only the highest level of the _type_ variable goes into the output.
The drop is because otherwise two additional variables, _type_, indicating combinations of the CLASS variables, and _freq_ would appear.
Mean= used this way with this procedure says "name the statistic mean with the original name of the variable". You could rename the results if desired.
Proc summary data=have nway; class id; var b w g; output out=want (drop= _: ) mean=; run;
Looks likely.
The NWAY means that only the highest level of the _type_ variable goes into the output.
The drop is because otherwise two additional variables, _type_, indicating combinations of the CLASS variables, and _freq_ would appear.
Mean= used this way with this procedure says "name the statistic mean with the original name of the variable". You could rename the results if desired.
data test;
input Id B w g;
cards;
1 8 . .
1 7 . .
1 . 6 .
1 . 5 .
1 . . 4
1 . . 5
2 4 . .
2 3 . .
2 . 6 .
2 . 2 .
2 . . 8
2 . . 4
;;;;
run;
proc print;
run;
proc summary data=test nway;
class id;
output out=means mean(b w g)=;
run;
proc print;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.