BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dcicantab5
Obsidian | Level 7

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;       

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

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

4 REPLIES 4
jklaverstijn
Rhodochrosite | Level 12

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,

jklaverstijn
Rhodochrosite | Level 12

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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