BookmarkSubscribeRSS Feed
Mo2018
Calcite | Level 5

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 

Capture555.PNGso 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 

1 REPLY 1
Reeza
Super User

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 

Capture555.PNGso 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 


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 879 views
  • 1 like
  • 2 in conversation