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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.