Hello everybody,
I want to make a table of a result of the mean procedure. I use codes below to run the mean statemant:
proc means data=have;
var x;
class name time;
run;
So, I want a table which keeps name, time and means of x variable as listed in the following table:
name | time | mean_x |
A | 1 | 12 |
A | 2 | 13 |
A | 3 | 12 |
A | 4 | 16 |
A | 5 | 9 |
B | 1 | 11 |
B | 2 | 12 |
B | 3 | 12 |
B | 4 | 14 |
B | 5 | 7 |
C | 1 | 11 |
C | 2 | 14 |
C | 3 | 13 |
C | 4 | 17 |
C | 5 | 11 |
How can I do that?
Thanks in advance.
This should work:
proc means data=have mean nway; var x; class name time; output out=want (drop= _: ) mean=mean_x; run;
This should work:
proc means data=have mean nway; var x; class name time; output out=want (drop= _: ) mean=mean_x; run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.