Hi, I am trying to plot the mean for each group over time
I have calculated the mean for each group at each time ( time from 1 to 7 i.e seven time points )
my output look like this
so I want to plot the group 1 with the first row( mtime1 to mtime7 over seven time pionts)
and same for group 2 with the second row and same with group 3
I tried to do something like that but it did not work
proc means data=insulin3 mean; by group;
var time1 time2 time3 time4 time5 time6 time7;
output out=new mean=mtime1 mtime2 mtime3 mtime4 mtime5 mtime6 mtime7;
run;
proc print data = new;
run;
proc sgplot data=new;
scatter x=group y=mtime1;
run; I used sgplot because proc gplot is not available in SAS studio.
thanks for your help
You need to change your data structure. If it's in a long format this is a trivial exercise.
Reformat your data to have:
Group Time Measurement
1 1 XX
1 2 XX
1 3 XX
...
2 1 XX
2 2 XX
..
4 7 XX
Then your graphing statement becomes:
proc sgplot data=transposed;
series x=time y=measurement / group=group;
run;
@Mo2018 wrote:
Hi, I am trying to plot the mean for each group over time
I have calculated the mean for each group at each time ( time from 1 to 7 i.e seven time points )
my output look like this
so I want to plot the group 1 with the first row( mtime1 to mtime7 over seven time pionts)
and same for group 2 with the second row and same with group 3
I tried to do something like that but it did not work
proc means data=insulin3 mean; by group; var time1 time2 time3 time4 time5 time6 time7; output out=new mean=mtime1 mtime2 mtime3 mtime4 mtime5 mtime6 mtime7; run; proc print data = new; run; proc sgplot data=new; scatter x=group y=mtime1; run;I used sgplot because proc gplot is not available in SAS studio.
thanks for your help
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.