The SAS Output Delivery System and reporting techniques

Mean with SE bars over time: i am stuck.. Need help

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Mean with SE bars over time: i am stuck.. Need help

I am on SAS studio,

trying to create a mean with SE bars over time ( hand hygiene compliance over time, 2 groups of wards ('0' composed of 6 wards with low bed occupancy rates and '1' composed of wards with high occupancy rates).

 

I referred to 

Sample 42542: Plot means with standard error bars from calculated data with PROC SGPLOT

 

Supposed to get 2 pairs of dots & 2 lines with error bars. Didn't happen:

 

meanSEfail.gif

Where did it go wrong?

 

my codes:

proc means data=WORK.HANDHYGIENE3 mean stderr;

class grouphh month;

var findings;

output out=out1hh mean = mean stderr=stderr;

run;

data reshape(drop=stderr);                                                                                                              

   set out1hh;                                                                                                                        

   lower=mean - stderr;                                                                                                                 

   upper=mean + stderr;                                                                                                                 

run;                                                                                                                                    

                                                                                                                                            

ods listing close;                                                                                                                      

                                                                   

ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             

                                                                                                                                        

proc sgplot data=reshape noautolegend;                                                                                                  

   scatter x=month y=mean / yerrorlower=lower                                                                                            

                           yerrorupper=upper                                                                                            

                           markerattrs=(color=blue symbol=CircleFilled);                                                                

   series x=month y=mean / lineattrs=(color=blue pattern=2);                                                                             

   title1 'Plot Means with Standard Error Bars from Calculated Data';                                                                   

run;       

Attachment

Accepted Solutions
Solution
‎06-13-2016 12:39 AM
Super Contributor
Posts: 406

Re: Mean with SE bars over time: i am stuck.. Need help

Maybe you need to group the series by grouphh:

 

series x=month y=mean / lineattrs=(color=blue pattern=2) group=grouphh;

That worked for me.

 

Regards,

- Jan.

View solution in original post


All Replies
Contributor
Posts: 22

Re: Mean with SE bars over time: i am stuck.. Need help

the data file

Super Contributor
Posts: 406

Re: Mean with SE bars over time: i am stuck.. Need help

Proc means will calculate stats for all permutations of the classification variables. Add the NWAY option to only keep the grouphh*month interactions. That will take care of the erratic lines in your plot.

 

proc means data=WORK.HANDHYGIENE3 mean stderr nway;

Hope this helps,

- Jan,

Contributor
Posts: 22

Re: Mean with SE bars over time: i am stuck.. Need help

Unknown_line.gif

Solution
‎06-13-2016 12:39 AM
Super Contributor
Posts: 406

Re: Mean with SE bars over time: i am stuck.. Need help

Maybe you need to group the series by grouphh:

 

series x=month y=mean / lineattrs=(color=blue pattern=2) group=grouphh;

That worked for me.

 

Regards,

- Jan.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 351 views
  • 2 likes
  • 2 in conversation