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;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.