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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.