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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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